Stt21-01 guruh talabsi Bozorboyev Suxrob 2-amaliy javoblari


IKKINCHI ASSISMENT TOPSHIRIG‘I


Download 32.83 Kb.
bet2/2
Sana17.06.2023
Hajmi32.83 Kb.
#1541689
1   2
Bog'liq
2-amaliy javoblari

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.
_______________________________ _______________________________
_______________________________






Download 32.83 Kb.

Do'stlaringiz bilan baham:
1   2




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling