Fayziyeva Zuxra
Variant № 8
ARRAYdagi oxirgi elementga ko‘rsatkich qaytaruvchi funksiya yozing.
|
#include
#include
#include
using namespace std;
int main(){
srand(time(0));
array sonlar;
for(int i=1; i<=30; i++){
sonlar[i] = rand()%30;
cout<}
cout<<"\n\nOxirgi elementi: "<}
Natija:
VECTOR o‘rtasidagi element o‘chirib tashlansin. Agar stek elementi toq bo‘lsa, bitta element, aks holda ikkita element o‘chirilsin.
|
#include
#include
#include
using namespace std;
int main(){
srand(time(0));
vectormyvector;
int n;
cin>>n;
for(int i=0;ifor(int i:myvector)cout<myvector.erase(myvector.begin()+myvector.size()/2);
if(n%2==0){
myvector.erase(myvector.begin()+myvector.size()/2);
}
cout<<"\n";
for(int i:myvector)cout<cout<<"\n";
return main();
}
Natija:
Do'stlaringiz bilan baham: |