Birinchi assisment topshirig‘i
|
|
STL kutubxonasiga oid berilgan quyidagi dastur bo‘yicha berilgan topshiriqlar kerakli fragmentlari asosida bajaring.
Bunda dasturdagi baʻzi o‘zgartirishlarni topish orqali topshiriqlar bosqichma – bosqich amalga oshiriladi.
|
dastur
|
topshiriqlar
|
#include
#include
using namespace std;
int main() {
vector v;
int i;
cout << v.size() << endl;
for (i = 0; i < 10; i++)
v.push_back(i);
cout << v.size() << endl;
for (i = 0; i < 10; i++)
cout << v[i] << " ";
cout < cout << v.front() << endl;
cout << v.back() << endl;
vector::iterator p = v.begin();
while (p != v.end()) {
cout << *p << " ";
p++;
}
system("pause");
return 0;
}
|
1. Dasturda STL kutubxonasining necha sinfi va uning funksiyalari ishlatilgan.
______________________________
________________________________
________________________________
|
2. Dasturdagi STL sinfni o‘zgartirib dasturni qaytadan tuzing. Qaysi qismlar o‘zgarganini qayd qiling.
________________________________
________________________________
________________________________
3. Dasturda vektor elementlariga haqiqiy tipli qiymatlarni berish uchun dastur fragment aniq yozing.
________________________________
________________________________
________________________________
________________________________
4. cout << v.front() << endl; fragmentga almatirish variantlarini aniqlang va dasturga yozib, tekshirib ko‘ring.
________________________________
________________________________
5. vector::iterator p = v.begin();
dasturning fragmentida nima o‘z aksini topgan.
________________________________
________________________________
________________________________
________________________________
|
6. Dasturda foydalanuvchi uchun chiqish ma’lumotlariga izoh bering. Dastruning tegishli bandlariga chiqish izohini qo’shib, qayta yozing.
7. Dasturda jami bo‘lib, necha o‘zgartirish kiritildi. _______________
7. Shu dasturning analogini yaratish sizga mustaqil vazifa.
|