}
int main()
{
int a,b,c,k;
cout<<"a="; cin>>a;
cout<<"b="; cin>>b;
cout<<"c="; cin>>c;
k=ekub(a,b,c);
cout<if(k==1)
cout<<"bu sonlar o`zaro tub";
else
cout <<"o`zaro tub emas";
return 0;
}
124. Berilgan natural sonni raqamlarini teskari tartibda almashtiring (masalan 65112 ni 21156 ko’rinishida chop etsin). #include //124-masala @TBCLbot
using namespace std;
int Teskari(int n)
{
int k=0,n=0;
while(n)
{
k=n%10;
s=s*10+k;
n/=10;
}
return s;
}
int main()
{
int n;
cout<return 0;
}
125. Tub son berilgan. O’zidan keyin keladigan tub sonlarni topadigan funksiya yarating. #include //125-masala @TBCLbot
using namespace std;
bool tub(int k)
{
int s=0;
for(int j=1;j<=k;j++)
if(k%j==0)
s++;
if(s==2)
return 1;
else return 0;
}
int main()
{
int k=0,m;
cin>>m;
while(k!=1)
{
k=0;
m++;
if(tub(m))
{
cout<k++;
}
}
return 0;
}
126. Quyidagi shartni qanoatlantiradigan abcd ko’rinishidagi barcha 4 xonali sonlarni toping: a, b, c, d – turli xil raqamlar (Masalan: 1203, 4871). #include //126-misol; @TBCLbot
using namespace std;
int main()
{
int n1,n2,n3;
for(int i=100;i<1000;i++)
{
n1=i/100;
n2=(i/10)%10;
n3=i%10;
if(n1!=n2&&n2!=n3&&n1!=n3)
cout<}
return 0;
}
127. m va n gacha hamma juft sonlar faktoriali yig’indisini hisoblash uchun dastur tuzing. #include //127-masala @TBCLbot
using namespace std;
long int Factor(int k)
{
int p=1;
for(int j=1;j<=k;j++)
p*=j;
return 1;
}
int main()
{
int m,n,s=0;
cout<<"n=";cin>>n;
cout<<"m=";cin>>m;
for(int i=n;i<=m;i++)
{
if(i%2==0)
s+=Factor(i);
}
cout<<"s="<return 0;
}
128. Davlatlarning nomi, poytaxti, aholisi, maydoni haqida struktura yarating va Eng ko’p aholiga, eng katta maydonga ega davlatning poytaxtini chop eting. #include //128-masala @TBCLbot
using namespace std;
//struktura hosil qilish
struct Malumot
{
string Nomi;
string Poytaxti;
int Hududi;
int Aholisi;
};
//Funksiya
void davlatlar(Malumot employee)
{
cout<<"\n===================================";
cout<<"\n Ma'lumot\n";
cout<<"\n Nomi : "<cout<<"\n Poytaxti : "<cout<<"\n Maydoni : "<cout<<"\n Aholi soni : "<cout<<"\n===================================";
}
int main()
{
string a,b,m1,m2,m3,a1,a2,b1,b2;
int d,c;
double m[3];
//birinchi davlat malumotlarini to'ldirish
cout<<" "<<1<<"-Davlat nomi: ";cin>>a;
cout<<" "<<1<<"-Davlat Poytaxti: ";cin>>b;
cout<<" "<<1<<"-Davlat Maydoni(km2 hisobida!): ";cin>>c;
cout<<" "<<1<<"-Davlat Aholi soni: ";cin>>d;
cout<<"\n******************************************************";
//birinchi davlat malumotlarini strukturaga kiritish
Malumot Davlat1={a,b,c,d};m[1]=c;m1=a;
//ikkinchi davlat malumotlarini to'ldirish
cout<<"\n "<<2<<"-Davlat nomi: ";cin>>a1;
cout<<" "<<2<<"-Davlat Poytaxti: ";cin>>b1;
cout<<" "<<2<<"-Davlat Maydoni(km2 hisobida!): ";cin>>c;
cout<<" "<<2<<"-Davlat Aholi soni: ";cin>>d;
cout<<"\n******************************************************";
//ikkinchi davlat malumotlarini strukturaga kiritish
Malumot Davlat2={a1,b1,c,d};m[2]=c;m2=a1;
//uchinchi davlat malumotlarini to'ldirish
cout<<"\n "<<2<<"-Davlat nomi: ";cin>>a2;
cout<<" "<<2<<"-Davlat Poytaxti: ";cin>>b2;
cout<<" "<<2<<"-Davlat Maydoni(km2 hisobida!): ";cin>>c;
cout<<" "<<2<<"-Davlat Aholi soni: ";cin>>d;
//uchinchi davlat malumotlarini strukturaga kiritish
Malumot Davlat3={a2,b2,c,d};m[3]=c;m3=a2;
davlatlar(Davlat1);
//Funksiyaga murojat
davlatlar(Davlat2);
davlatlar(Davlat3);
//Eng katta maydonga ega davlatni topish
if(m[2]<=m[1]&&m[1]<=m[3])
cout<<"\n Eng katta maydonga ega davlat: "<else if(m[1]<=m[2]&&m[2]<=m[3])
cout<<"\n Eng katta maydonga ega davlat: "<else if(m[1]<=m[3]&&m[3]<=m[2])
cout<<"\n Eng katta maydonga ega davlat: "<else if(m[3]<=m[1]&&m[1]<=m[2])
cout<<"\n Eng katta maydonga ega davlat: "<else if(m[3]<=m[2]&&m[2]<=m[1])
cout<<"\n Eng katta maydonga ega davlat: "<else if(m[2]<=m[3]&&m[3]<=m[1])
cout<<"\n Eng katta maydonga ega davlat: "<return 0;
}
129. a1,a2,… ,annatural sonlar ketma-ketligi berilgan. Bu ketma-ketlikdagi juft sonlardan massiv yarating. Agar bunday sonlar mavjud bo’lmasa, bu haqda xabar berilsin. #include //129-masala @TBCLbot
using namespace std;
int main()
{
int m=0,n,j=0,b;
cout<<"n=";cin>>n;
int a[n];
for(int i=1;i<=n;i++)
{
if(b%2==0)
a[j]=b;
j++;
m++;
}
if(m>=1)
{
for(j=1;j<=m;j++)
cout<}
else cout<<"juftsonlar yo'q";
return 0;
}
130. a1,a2,… ,an haqiqiy sonlar berilgan. Eng katta va eng kichik elementlar yig’indisini toping #include //130-masala @TBCLbot
using namespace std;
int main()
{
int n,max1,min1,a;
cout<<"n=";cin>>n;
cin>>a;
max1=min1=a;
for(int i=2;i<=n;i++)
{
cin>>a;
if(max1if(min1>a)min1=a;
}
cout<<"max+min:"<return 0;
}
131. a1,a2,… ,an butun sonlar berilgan. Faqat ai≥i shartni qanoatlantiruvchi sonlarni chop qiling. #include //131-masala @TBCLbot
using namespace std;
int main()
{
int n,a;
cout<<"n=";cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a;
if(a>=i)
cout<}
return 0;
}
132. Haqiqiy sonli massivning berilgan sondan kichik barcha elementlari ko’paytmasini toping. #include //132-masala @TBCLbot
using namespace std;
int main()
{
int n;
cout<<"n=";cin>>n;
float a[n],p=1,k;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
cout<<"k=";cin>>k;
for(int i=1;i<=n;i++)
if(a[i]p*=a[i];
cout<<"Ko'paytma:p="<
return 0;
}
133. Massivning 3 va 9 ga karrali elementlari ko’paytmasini toping. #include //133-masala @TBCLbot
using namespace std;
int main()
{
int n;
cout<<"n=";cin>>n;
float a[n];
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
cout<<"\n3 va 9 ga karrali elementlar:\n";
for(int i=1;i<=n;i++)
if(a[i]%3==0||a[i]%9==0)
cout<return 0;}
134. a1,a2,… ,an haqiqiy sonlar berilgan. Eng katta va eng kichik elementlarini ko’paytiring. #include //134-masala @TBCLbot
using namespace std;
int main()
{
int n;
float max1,min1,a;
cout<<"n=";cin>>n;
cin>>a;
max1=min1=a;
for(int i=2;i<=n;i++)
{
cin>>a;
if(max1if(min1>a)min1=a;
}
cout<<"max*min:"<return 0;
}
135. Teng yonli uchburchakning elementlari quyidagi tartibda nomerlangan. 1-katet a, 2-gipotenuza , 3-gipotenuzaga tushirilgan balandlik h=c/2, 4-yuzasi S= . Shu elementlardan bittasi berilganda qolganlarini topuvchi programma tuzilsin. #include //135-masala @TBCLbot
using namespace std;
int main()
{
int n;
cin>>n;
float a,c,h,s;
switch(n)
{
case 1:{cout<<"a=";cin>>a;c=a*sqrt(2);h=(c/2);s=c*h*1./2;cout<<"c="<case 2:{cout<<"c=";cin>>c;a=c*1./sqrt(2);h=c/2;s=c*h*1./2;cout<<"a="<case 3:{cout<<"h=";cin>>h;a=sqrt(2)*h;c=2*h;s=c*h*1./2;cout<<"a="<case 4:{cout<<"s=";cin>>s;a=sqrt(2*s);c=2*sqrt(s);h=sqrt(h);cout<<"c="<default :cout<<"1-4 oralig'idagi son kiriting!";
}
return 0;
}
136. Og'irlik birliklari quyidagi tartibda berilgan. 1-kilogramm, 2-milligramm, 3-gramm, 4-tonna, 5-sentner. Og'irlik birligini bildiruvchi soni berilgan va shu birlikdagi og'irlik qiymati berilgan. Og'irlikni kilogramda ifodalovchi programma tuzilsin. #include //136-masala @TBCLbot
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
switch(n)
{
case 1:{cout<<"m="<case 2:{cout<<"m="<case 3:{cout<<"m="<case 4:{cout<<"m="<case 5:{cout<<"m="<default :cout<<"1-5 oralig'idagi son kiriting!";
}
return 0;
}
137. 1-7 gacha bo’lgan butun sonlar berilgan. Kiritilgan songa mos ravishda hafta kunlarini so’zda ifodalovchi programma tuzilsin. (1-Dushanba,2-Chorshanba,...h.k). #include //137-masala @TBCLbot
using namespace std;
int main()
{
int n;
cin>>n;
switch(n)
{
case 1:cout<<"Dushanba";break;
case 2:cout<<"Seshanba";break;
case 3:cout<<"Chorshanba";break;
case 4:cout<<"Payshanba";break;
case 5:cout<<"Juma";break;
case 6:cout<<"Shanba";break;
case 7:cout<<"Yakshanba";break;
default :cout<<"Bunaqqa hafta kuni yo'q!";
}
return 0;
}
138. a, b, c butun sonlar berilgan. Jumlani rostlikka tekshiring: „a, b, c tomonli uchburchak teng tomonli bo’ladi”. #include //138-masala @TBCLbot
using namespace std;
int main()
{
float a,b,c;
cin>>a>>b>>c;
if(a==b&&b!=c&&a!=c)
cout<<"Rost";
else if(b==c&&b!=a&&c!=a)
cout<<"Rost";
else if(c==a&&a!=b&&c!=b)
cout<<"Rost";
else cout<<"Yolg'on";
return 0;
}
139. a, b, c butun sonlar berilgan. Jumlani rostlikka tekshiring: „a, b, c tomonli uchburchak teng yonli bo’ladi”. #include //139-masala @TBCLbot
using namespace std;
int main()
{
float a,b,c;
cin>>a>>b>>c;
if(a==b&&b!=c&&a!=c)
cout<<"Rost";
else if(b==c&&b!=a&&c!=a)
cout<<"Rost";
else if(c==a&&a!=b&&c!=b)
cout<<"Rost";
else cout<<"Yolg'on";
return 0;
}
140. a, b, c butun sonlar berilgan. Jumlani rostlikka tekshiring: „a, b, c tomonli uchburchak to’g’ri burchali bo’ladi”. #include //140-masala @TBCLbot
using namespace std;
int main()
{
float a,b,c;
cin>>a>>b>>c;
if(a*a+b*b==c*c)
cout<<"Rost";
else if(a*a+c*c==b*b)
cout<<"Rost";
else if(c*c+b*b==a*a)
cout<<"Rost";
else cout<<"Yolg'on";
return 0;
}
141. a, b, c butun sonlar berilgan. Jumlani rostlikka tekshiring: „a, b, c tomonli uchburchak yasash mumkin”. #include //141-masala @TBCLbot
using namespace std;
int main()
{
float a,b,c;
cin>>a>>b>>c;
if(a+b>c&&a+c>b&&b+c>a)
cout<<"rost";
else cout<<"Yolg'on";
return 0;
}
142. Ixtiyoriy a, b lar uchun ax3+bx=0 tenglamani yechadigan dasturni yozing. Barcha haqiqiy yechimlar topilsin. #include //142-masala @TBCLbot
using namespace std;
int main()
{
float a,b,x1,x2;
cin>>a>>b;
x1=0;
x2=sqrt(b*1./a);
cout<<"x1="<return 0;
}
143. Berilgan uchta son asosida, ulardan ixtiyoriy ikkitasining yig’indisi musbat ekanligini aniqlovchi dastur tuzing. #include //143-masala @TBCLbot
using namespace std;
int main()
{
float a,b,c;
cin>>a>>b>>c;
if(a+b>0||a+c>b||b+c>a)
cout<<"rost";
else cout<<"Yolg'on";
return 0;
}
144. To’rtta a1, a2, a3 va a4sondan bittasi, o’zaro teng bo’lgan boshqa uchtasidan farqli ekanligi ma’lum, shu songa n o’zgaruvchi raqamini bering. #include //144-masala @TBCLbot
using namespace std;
int main()
{
int a,b,c,d,n;
cin>>a>>b>>c>>d;
cout<<"n=";cin>>n;
if(a==b && b==c)d=n;
else
if(a==b && b==d)c=n;
else
if(a==c && c==d)b=n;
cout<<"a1:"<cout<<"a2:"<cout<<"a3:"<cout<<"a4:"<return 0;
}
145. Markazi (x1,y1) nuqtada bo’lgan R radiusli aylana bilan (x0,y0) koordinatali nuqtaning o’zaro joylashish holatini aniqlovchi dastur tuzing. #include //145-masala @TBCLbot
using namespace std;
int main()
{
float x,y,x1,y1,r,n;
cout<<"Aylana koordinatalari:";cin>>x>>y;
cout<<"Nuqta (x1,y1):";cin>>x1>>y1;
cout<<”Aylana radiusi:”;cin>>r;
n=sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1);
if(r>n)cout<<"nuqta aylana ichida joylashgan";
else if(nelse cout<<"Nuqta aylana markazida joylashgan";
return 0;
}
146. Manfiy bo’lmagan a butun sonni b musbat songa bo’lgandan hosil bo’lgan qoldig’i, berilgan c yoki d sonlarning birortasiga tengligini aniqlang. #include //146-masala @TBCLbot
using namespace std;
int main()
{
int a,b,c,d;
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
if(a%b==c||a%b==d)
{
if(a%b==c)
cout<<"a ni b ga bo'lgandagi qoldiq c";
else
cout<<"a ni b ga bo'lgandagi qoldiq d";
}
else
cout<<"a ni b ga bo'lgandagi qoldiq c ga ham d ga ham teng emas";
return 0;
}