36
1-misol. Kiritilgan sonni so’zlar bilan ifodalaydigan dasturni yaratish.
Dastur kodi:
string a[]={"bir","ikki","uch","to'rt","besh","olti","yetti","sakkiz","to'qqiz"};
string b[]={"o'n","yigirma","o'ttiz","qirq","ellik","oltmish","yetmish",
"sakson","to'qson"};
string nat="";
int n,g,k,p,x;
cout<<"SONNI KIRITING= ";
cin>>n;
x=n/1000;
if(x>=1) {nat=nat+a[x-1]+" ming ";}
if(n%1000==0) {nat=nat;}
cout<<" ";
n=n%1000;
p=n/100;
if(p>=1) {nat=nat+a[p-1]+" yuz ";}
if(n%100==0) {nat=nat;}
n=n%100;
k=n/10;
if(k>=1) {nat=nat+b[k-1]+" ";}
if(n%100==0) {nat=nat;}
g=n%10;
if(g>=1) {nat=nat+a[g-1]+" ";}
if(n%100==0) {nat=nat;}
cout<
Natija:
1-rasm.
Har bir talaba o’zining tug’ilgan kuni va oyini sonlar orqali kiritib, uni yozuvdagi
ko’rinishini hosil qilishi zarur .(Masalan talaba 2608 da tug’ilgan bo’lsa, ekranga : ikki
ming olti yuz sakkiz holatida chiqshi kerak).
Do'stlaringiz bilan baham: