6-amaliy mashg’ulot


Download 0.59 Mb.
bet3/3
Sana23.12.2022
Hajmi0.59 Mb.
#1045573
1   2   3
Bog'liq
640-21 Mo`moniv Anvarjon 6-10........

10-amaliy mashg’ulot da savollar kamligi uchun men 10-raqamdagi savolni ishladim savolar soni 20 ta ekan men 30 da turaman
10.Ixtiyoriy nomda dek e’lon qilinsin, ASC II kod jadvali asosida shunday belgilar dekga kiritilsinki, dekni ekranga chiqarganimizda 80 dan boshlab 90 gacha sonlar ekranga chiqarilsin.


#include #include using namespace std; int a[10],n,R=0; bool isEmpty(){

if(R==0) return true; else return false;

bool isFull(){

if(R>=10) return true; else return false;

}

int kirit_left(int s){

if(isFull()){cout<<"\ndek to'ldi";n=R;return EXIT_SUCCESS;} for(int i=R;i>0;i--)

a[i]=a[i-1]; a[0]=s;R++;

}

int olish_left(){

if(isEmpty()){cout<<"\ndek bo'sh";return EXIT_SUCCESS;} int t=a[0];

for(int i=0;i

R--;


return t;

}

int kirit_right(int s){



if(isFull()){cout<<"\ndek to'ldi";n=R;return EXIT_SUCCESS;} a[R]=s;R++;

}

int olish_right(){



if(isEmpty()){cout<<"\ndek bo'sh";return EXIT_SUCCESS;} R--;

return a[R];

}

int print(){



cout<

}

int main(int argc, char *argv[])



{ int n,s;cout<<"n="; cin>>n; for(int i=0;i

if(!isFull()){ cout<<"kirit=";cin>>s; if(i>=n/2) kirit_right(s); else kirit_left(s);}

else {cout<<"dek to'ldi\n";break;}

}

print();



int b[n/2],k=0,c[n/2],p=0;

while(!isEmpty()){

int q=olish_left(); if(q%2==0) b[k++]=q; if(isEmpty()) break;

int p=olish_right(); if(p%2==0) b[k++]=p;

}

int i=0; while(i



kirit_right(b[i]); i++;

}

print(); system("PAUSE"); return EXIT_SUCCESS;



}

Download 0.59 Mb.

Do'stlaringiz bilan baham:
1   2   3




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling