912-21 guruh
Sadullayev omonboy
6-labaratoriya
7. Iteratorlardan foydalanib vector konteyneri ustida amallar bajaring;
#include
#include
#include
using namespace std;
int main (){
vectora;
int n,x,c,s=0;
cout<<"Vector o'lchamini kiriting: ";
cin>>n;
vector::iterator itr;
for(int i=0;icout<<"vectorning "<>x;
a.push_back(x);
} A:
cout<<"Tanlang \n 1.Qo'shish 2.Juft qiymati 3. Toq qiymati \n";
cin>>c;
switch(c){
case 1:for(itr=a.begin();itr s+=*itr;} cout<case 2: for(itr=a.begin();itrif(*itr%2==0)
cout<<"Juft qiymat:"<<*itr<<"\n";} goto A;
case 3: s=*itr; for(itr=a.begin();itr if(*itr%2!=0) cout<<"Toq qiymat:"<<*itr<<"\n"; } goto A;
}
return 0;
}
Do'stlaringiz bilan baham: |