1. Kompyuter nima hardware, software
Download 0.75 Mb.
|
Oraliq javoblari
factorial(n) ni hisoblash uchun rekursiv algoritmni soddagina qilib, quyidagicha yozishimiz mumkin:
if(n == 0) return 1; elsereturnn*factoriaL(n-1); Rekursiv chaqirish bir qancha rekursiv chaqirishlarni sodir etishi mumkin, chunki, funksiya quyi pog`onali masalani bir nechta quyi pog`onali masalalarni hisoblash orqali hisoblaydi. Rekursiv funksiya ishini to`xtatishi uchun masala so`nggi hisoblash holatiga qadar qayta ko`rib chiqilaverishi kerak. So`nggi hisoblash holatida funksiya uning chaqiruvchisiga qiymat qaytaradi, qiymatni qabul qilib olgan funksiya esa, o`zining chaqiruvchisiga qiymat yuboradi. Bu jarayon original (asosiy) masalaga qiymat yuborilguncha davom etadi. Va nihoyat, original masala factorial(n-1) ning yuborgan qiymatiga n ni ko`paytirishi va natijani qaytarishi mumkin. 82-misol #include intry(int n) { if(n<1) { return 0; } else { return n%10+ry(n/10); } } int main() { int n; cin>>n; cout<<"Natijasi="; cout< #include #include using namespace std; int main() { double v0,v1,t,a; cin>>v0>>v1>>t; a=(v1-v0)/t; cout<84-misol #include using namespace std; int main() { inta,b,c; c in>>a;b=a/100; cout<cout< #include #include using namespace std; int main() { doublea,b,c,x,s; cout<<"Masofanikiriting:";cin>>a; cin>>b; cout<<" kmga 10 litrbenzinsarfqiladi"< cin>>c; x=a/b*10;s=x*c; cout<<"Jami sarfxarajatlar:"< #include using namespace std; int main() { doublea,b,c,d; cin>>a>>b>>c; d=max(max(a,b),c); cout<<"Engkatta son bu "< #include using namespace std; int main () { inta,b,c,d,e,f; cin>>a>>b>>c; d=max(max(a,b),c); e=min(min(a,b),c); f=a+b+c-d-e; cout< #include using namespace std; int main() { doublex,y,r; cout<<"Radiusnikiriting: "; cin>>r; cout<<"Koordinatalarnikiriting: "; cin>>x>>y; if(sqrt(x*x+y*y)<=r) cout<<"Nuqtaaylanaichidayotadi"; elsecout<<"Nuqtaaylanaichidayotmaydi"; } 89-misol #include using namespace std; int main() { inta,b,c,d; cin>>a; if(a%10==a || a/10==a%10 ) cout<<"Kiritganraqamizpalindrom"; b=a%100; c=b%10; d=a/100; if(c==d) cout<<"Kiritganraqamizpalindrom"; elsecout<<"Kiritganraqamizpalindromemas"; } 90-misol #include #include using namespace std; int main() { int a; cout<<" Sonnikiriting "; cin>>a; switch (a) { case 0:cout<<"0"< return 0;} 91-misol #include #include cout<< "Birinchishaharnikiriting: "; getline(cin, city1); cout<< "Ikkinchishaharnikiriting: "; getline(cin, city2); cout<< "Uchinchishaharnikiriting: "; getline(cin, city3); cout<< "Shaharlarningalfavitbo'yichatartibi ==> "; if (city1 < city2 && city2 #include using namespace std; int main() { float S=0; for(inti=1; i<=97; i+=2) { S+=i/(i+2.0); } cout< #include using namespace std; int main() {stringa;intn; getline(cin,a); n=a.length(); for(inti=0;i #include using namespace std; int main() { string a; int n; getline(cin,a); n=a.length(); for(inti=1;i #include #include using namespace std; voidaniqla(int n) { if(n>=0) cout<<"Musbat son "; else cout<<"Manfiy son "; } int main() { int n; cin>>n; aniqla(n); } 97-misol #include #include using namespace std; int main() { double a[100],s=0,n,kam=0,kup=0; for(inti=1; i<=100; i++){ cin>>a[i]; if(a[i]<0){ break; } s=s+a[i]; n=i; } s=s/n; for(inti=1; i<=n; i++){ if(a[i]>s) { kup++; } else{ kam++; } }cout<<"o'rtachaqiymatidanyuqori ="< #include #include using namespace std; int main() { int n,s=0; srand(time(0)); for(intj=0;j<10;j++) { for(inti=0;i<100;i++) { n=rand()%10; if(j==n) s++; } cout< 99-misol #include #include #include #include using namespace std; int main() {int mass[4][4],s,p; srand(time(0)); for (inti=1;i<=4;i++){ cout< for (inti=1;i<=4;i++){ cout< cout< s+=mass[i][j]; } p=0; p+=s; } }cout< 100-misol #include #include #include #include using namespace std; int main() {intn,i,k,f,j,s,p,d,l=0,o=0; srand(time(0)); cin>>n; int a[n][n],b[n][n],c[n][n]; for(inti=1;i<=n;i++) { cout< cout< b[k][f]=rand()%10; cout< cout< c[o][l]=a[o][l]+b[o][l]; cout< #include using namespace std; float m(float i) { if(i<1) return 0; else return (i)/(i*2+1)+m(i-1); } int main() { int a; cin>>a; cout< Download 0.75 Mb. Do'stlaringiz bilan baham: |
Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling
ma'muriyatiga murojaat qiling