Yangi konteynerlar hosil qiling, uni standart funksiyalar yordamida elementlar bilan to’lating va
Download 180.44 Kb.
|
Yangi konteynerlar hosil qiling uni
Yangi konteynerlar hosil qiling, uni standart funksiyalar yordamida elementlar bilan to’lating va for_each funksiyasi yordamida uni chop qiling; Iteratorlardan foydalanib list konteyneri ustida amallar bajaring calloc () funksiyasidan foydalanib xotirani dinamik taqsimlashni amalga oshiring . #include "stdafx.h" #include #include #include #include #include using namespace std;
int main() { int n,x;
cout << "Listning o'lchamini kiriting: "; cin >> n; list for (int i = 0; i < n; i++){ x = rand() % 11 - 5;
cout << i + 1 << " - " << x< }
for (int y : bol){ cout << y << endl; } return 0; } b) #include "stdafx.h" #include #include #include #include #include #include #include void teskari(list { copy(list.rbegin(), list.rend(), ostream_iterator cout << '\n'; } int main() { int n,x;
cout << "Listning o'lchamini kiriting: "; cin >> n; list for (int i = 0; i < n; i++){ x = rand() % 11 - 5;
cout << i + 1 << " - " << x< }
cout < system("pause"); c)
#include using namespace std; int main() { int n; cout<<"elementlar sonini kiriting: "; cin>>n;
int *ptr; ptr = (int*) malloc(n*sizeof(int)); if(!ptr) { cout << "Memory Allocation Failed"; exit(1); } cout << "natijalar yuklanmoqda..." << endl << endl; for (int i=0; i { ptr[i] = i*2+1; } cout << "yuklangan natijalar" << endl; for (int i=0; i {
cout << *(ptr+i) << endl; return 0; } Download 180.44 Kb. Do'stlaringiz bilan baham: |
ma'muriyatiga murojaat qiling