Muhammad al-Xorazmiy
nomidagi nomidagi TATU ning 310-20 guruh
talabasi Xajiqurbonov Azizbekning
dasturlash 2 fanidan bajargan
4-topshirig’i
20
Yangi konteynerlar hosil qiling, uni standart funksiyalar yordamida elementlar bilan to’lating is_sorted_until funksiyasi yordamida amallar bajaring;
Iteratorlardan foydalanib list konteyneri ustida amallar bajaring;
realloc () funksiyasidan foydalanib xotirani dinamik taqsimlashni amalga oshiring .
2
#include
#include
#include
using namespace std;
int main(){
listlst;
int a,b,c;
cin>>a;
for(int i=0;i
cin>>b;
lst.push_back(b);
}
lst.sort([](long long a,long long b){ return a>b; });
list::iterator t;
for(t=lst.begin();t!=lst.end();t++) cout<<*t<<" ";
}
3
#include
using namespace std;
int main(){
int *mac,m,n;
cout<<"n = "; cin>>n;
mac=(int*)realloc(mac,n*sizeof(int));
for(int i=0;i
cin>>mac[i];
}
for(int i=0;i
cout<
}
system("Pause");
return 0;
}
Dostları ilə paylaş: |