IKKINCHI ASSISMENT TOPSHIRIG‘I
|
Konteyner sinflarga oid berilgan quyidagi dastur bo‘yicha berilgan topshiriqlar kerakli fragmentlari asosida bajaring.
Bunda dasturdagi baʻzi o‘zgartirishlarni topish orqali topshiriqlar bosqichma – bosqich amalga oshriladi.
|
7. Dasturning analog ko’rinishi
|
topshiriqlar
|
#include
#include
#include
#include
int main() {
std::vector myVector;
for (int count = 0; count < 5; ++count)
myVector.push_back(count);
std::vector::const_iterator itV;
itV = myVector.begin();
while (itV != myVector.end()) {
std::cout << *itV << " ";
++itV;
}
std::cout << '\n';
std::list myList;
for (int count = 0; count < 5; ++count)
myList.push_back(count);
std::list::const_iterator itL;
itL = myList.begin();
while (itL != myList.end())
{
std::cout << *itL << " ";
++itL;
}
std::cout << '\n';
std::set mySet;
mySet.insert(28);
mySet.insert(01);
mySet.insert(80);
mySet.insert(9);
mySet.insert(3);
std::set::const_iterator itS;
itS = mySet.begin();
while (itS != mySet.end())
{
std::cout << *itS << " ";
++itS;
}
std::cout << '\n';
return 0;
}
|
1. Dasturdagi eng katta xatoni toping.
Javobi: Dasturda bir xatolik yo'q. Kod to'g'ri va natijada konsolda quyidagi chiqarishni ko'rsatadi:
0 1 2 3 4
0 1 2 3 4
1 3 9 28 80
|
|
3. itV qanday konteyner va nima uchun.
Javobi : itV bir iterator o'zgaruvchisidir. Bu iterator std::vector sinfida foydalanilgan vektor elementlarini yurish uchun ishlatiladi.
_______________________________ _______________________________
_______________________________
|
|