1. Kompyuter nima hardware, software


Download 0.75 Mb.
bet19/19
Sana28.12.2022
Hajmi0.75 Mb.
#1070487
1   ...   11   12   13   14   15   16   17   18   19
Bog'liq
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 using namespace std;
intry(int n) { if(n<1) { return 0; }
else { return n%10+ry(n/10); } }
int main() { int n; cin>>n; cout<<"Natijasi="; cout<83-misol
#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<85-misol
#include
#include
using namespace std;
int main() { doublea,b,c,x,s;
cout<<"Masofanikiriting:";cin>>a;
cin>>b; cout<<" kmga 10 litrbenzinsarfqiladi"<cout<<"Birlitrbenzinnarxinikirting:";
cin>>c; x=a/b*10;s=x*c;
cout<<"Jami sarfxarajatlar:"<86-misol
#include clude
using namespace std; int main() { doublea,b,c,d; cin>>a>>b>>c;
d=max(max(a,b),c); cout<<"Engkatta son bu "<87-misol
#include #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<88-misol
#include 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 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
#include
using namespace std;
int main() { int a; cout<<" Sonnikiriting "; cin>>a;
switch (a) {
case 0:cout<<"0"<case 1:cout<<"1"<case 2:cout<<"2"<case 3:cout<<"3"<case 4:cout<<"4"<case 5:cout<<"5"<case 6:cout<<"6"<case 7:cout<<"7"<case 8:cout<<"8"<case 9:cout<<"9"<case 10:cout<<"A"<case 11:cout<<"B"<case 12:cout<<"C"<case 13:cout<<"D"<case 14:cout<<"E"<case 15:cout<<"F"<default: cout<<"Bu qiymatnikiritishmumkinemas"; }
return 0;}
91-misol
#include
#include using namespace std; int main() { string city1, city2, city3;
cout<< "Birinchishaharnikiriting: ";
getline(cin, city1);
cout<< "Ikkinchishaharnikiriting: ";
getline(cin, city2);
cout<< "Uchinchishaharnikiriting: ";
getline(cin, city3); cout<< "Shaharlarningalfavitbo'yichatartibi ==> "; if (city1 < city2 && city2if (city1 < city3 && city3cout<< city1 << " " << city3 << " " << city2 <if (city2 < city1 && city1cout<< city2 << " " << city1<< " " << city3 <if (city2 < city3 && city3cout<< city2 << " " << city3<< " " << city1 <if (city3 < city2 && city2cout<< city3 << " " << city2<< " " << city1 <if (city3 < city1 && city1cout<< city3 << " " << city1<< " " << city2 <92-misol
#include nclude
using namespace std;
int main() { float S=0; for(inti=1; i<=97; i+=2) { S+=i/(i+2.0); } cout<93-misol
#include #include
using namespace std;
int main() {stringa;intn;
getline(cin,a); n=a.length();
for(inti=0;icout<94-misol
#include #include #include
using namespace std;
int main() { string a; int n;
getline(cin,a); n=a.length();
for(inti=1;icout<95-misol
#include #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 ="<cout<<"o'rtachaqiymatidan past ="<98-misol
#include #include
#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<s=0;} return 0; }
99-misol
#include
#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<mass[i][j]=rand()%10;}}
for (inti=1;i<=4;i++){ cout<for (int j=1;j<=4;j++){
cout<for (inti=1;i<=4;i++){ cout<for (int j=1;j<=4;j++) {if(i==j) {
s+=mass[i][j]; } p=0; p+=s; }
}cout<
100-misol
#include
#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<for(int j=1;j<=n;j++) { a[i][j]=rand()%10; cout<cout<for(int k=1;k<=n;k++){
cout<for(int f=1;f<=n;f++){
b[k][f]=rand()%10;
cout<cout<for(int o=1;o<=n;o++){
cout<for(int l=1;l<=n;l++){
c[o][l]=a[o][l]+b[o][l];
cout<cout<101-misol
#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:
1   ...   11   12   13   14   15   16   17   18   19




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