Nazariy qism(1-90) Massivlarni saralash algoritmlari


Uchburchakning perimetrini va yuzasini funksiyadan foydalanib toping



Download 265,24 Kb.
bet66/66
Sana31.12.2021
Hajmi265,24 Kb.
#257465
1   ...   58   59   60   61   62   63   64   65   66
Bog'liq
Yakuniy Javoblari @TBCLbot 2021

115. Uchburchakning perimetrini va yuzasini funksiyadan foydalanib toping.

#include

//115-misol; @TBCLbot

using namespace std;

int yuza(int a, int b,int c,float p)

{

float s;


s=sqrt((p/2)*((p/2)-a)*((p/2)-b)*((p/2)-c));

return s;

}

int perimetr(int a,int b,int c)



{

float p;


p=a+b+c;

return p;

}

int main()



{

int a,b,c,p,s;

cout<<"uchburchak tomonlari kiriting : "<

cin>>a>>b>>c;

cout<

cout<



return 0;

}

116. Talabalar familyasi, ismi, kursi, reyting bali haqida structura yarating. X kursdagi 4 bahoga o‘qiydigan talabalar familya va ismini aniqlang.

#include

//116-misol @TBCLbot

using namespace std;

struct Sinf

{

string ism,familiya;



int kurs,ball;

};

int main()



{

Sinf a[100];

int X,n;

cout<<"Talabalar soni:n=";cin>>n;

for(int i=1;i<=n;i++)

{

cout<>a[i].ism;



cout<<"Talaba familiyasi:";cin>>a[i].familiya;

cout<<"Talaba Kursi:";cin>>a[i].kurs;

cout<<"Talaba Reytingi:";cin>>a[i].ball;

cout<<"\n*********************************\n";

}

cout<<"\n Kursni kiriting X=";cin>>X;



for(int i=1;i<=n;i++)

{

if(a[i].kurs==X)



{

cout<

cout<

}

}



return 0;

}

117. Talabalar familyasi, ismi, kursi, reyting bali haqida structura yarating. X kursdagi eng a‘lochi talabani familya va ismini aniqlang.

#include

//117-misol @TBCLbot

using namespace std;

struct Sinf

{

string ism,familiya;



int kurs,ball;

};

int main()



{

Sinf a[100];

int X,n;

cout<<"Talabalar soni:n=";cin>>n;

for(int i=1;i<=n;i++)

{

cout<>a[i].ism;



cout<<"Talaba familiyasi:";cin>>a[i].familiya;

cout<<"Talaba Kursi:";cin>>a[i].kurs;

cout<<"Talaba Reytingi:";cin>>a[i].ball;

cout<<"\n*********************************\n";

}

cout<<"\n Kursni kiriting X=";cin>>X;



int k=0,m=0;

for(int i=1;i<=n;i++)

{

if(a[i].kurs==X)



{

if(a[i].ball>m)

{

m=a[i].ball;



k=i;

}}

}



cout<

cout<

return 0;

}

118. Uchta uchburchak tomonlari bilan berilgan. Bu uchburchaklarning eng katta yuzaga ega bo’lganini nomerini toping.

#include

//118-masala @TBCLbot

using namespace std;

float Yuza(float a,float b,float c)

{

float s,p;



p=(a+b+c)*1./2;

s=sqrt(p*(p-a)*(p-b)*(p-c));

return s;

}

int main()



{

float a1,b,c;

float a[3];

for(int i=1;i<=3;i++)

{

cout<>a1>>b>>c;



a[i]=Yuza(a1,b,c);

}

int m=a[1],i;



for(i=1;i<=3;i++)

if(m

for(i=1;i<=3;i++)

{

if(a[i]==m)



{

cout<<"Eng katta yuzaga ega bo’lgan uchburchak nomeri: "<

}

}

return 0;



}

119. Aylanalar radiuslari bilan berilgan. Qaysi aylanadan eng katta yuzali doira kesib olish mumkin.

#include

//119-masala @TBCLbot

using namespace std;

float Yuza(float r)

{

return M_PI*r*r;



}

int main()

{

float r;


float a[3];

for(int i=1;i<=3;i++)

{

cout<>r;



a[i]=Yuza(r);

}

int m=a[1];



for(int i=1;i<=3;i++)

if(m

for(int i=1;i<=3;i++)

{

if(a[i]==m)



{

cout<<"eng katta yuzali doira nomeri: "<

break;

}

}



return 0;

}

120. N ta natural sonning EKUBini aniqlang.

#include

//120-misol @TBCLbot

using namespace std;

int ekub(int a,int b)

{

while(b)


{

a%=b;


swap(a,b);}

return a;

}

int main()



{

int n;


cout<<"n="; cin>>n;

int a,b,i=1;

cout<<" "; cin>>a;

while(i

{

cout<<" ";cin>>b;



a=ekub(a,b);

i++;


}

cout <<"kiritilgan n ta sonnig EKUB :"<

return 0;

}

121. [N;M] oralig’ida joylashgan tub sonlardan massiv hosil qiling.

#include

//121-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,m,n;

cout<<"n=";cin>>n;

cout<<"m=";cin>>m;

k=n;

while(k<=m)



{

if(tub(k))

{

cout<

}

k++;


}

return 0;

}

122. EKUB(a,b,c) ni aniqlang.

#include

//122-misol @TBCLbot

using namespace std;

int ekub(int a,int b,int c)

{

while(b)



{

a%=b;


swap(a,b);}

while(a)


{

c%=a;


swap(a,c);}

return c;

}

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 <<"EKUB(a,b,c) :"<

return 0;

}

123. Berilgan uchta sonning o’zaro tub ekanligini aniqlovchi dastur tuzing.

#include

//123-misol; @TBCLbot

using namespace std;

int ekub(int a,int b,int c)

{

while(b)



{

a%=b;


swap(a,b);}

while(a)


{

c%=a;


swap(a,c);

}

return c;



}

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,… ,an natural 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(max1

if(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(max1

if(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="<

}

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="<

else cout<<"Yolg'on";

return 0;

}

144. To’rtta a1, a2, a3 va a4 sondan 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(n

else 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;

}

147. a, b, c uchta haqiqiy sonlar berilgan. Hech bo’lmaganda bitta juftlikning o’zaro teng sonlar ekanligini aniqlash dasturini tuzing.

#include

//147-masala @TBCLbot

using namespace std;

int main()

{

int a,b,c;



cin>>a>>b>>c;

cout<<"n=";cin>>n;

if(a==b || b==c || c==a)

{

if(a==b);



cout<<"a son b ga teng";

else if(b==c)

cout<<"b son c ga teng";

else


cout<<"c son a ga teng";

}

else cout<<"a,b,c sonlardan birortasi bir-biriga teng emas!";



return 0;

}

148. a, b, c tomonli uchburchakning teng yonli ekanligini aniqlang.

#include

//148-masala @TBCLbot

using namespace std;

int main()

{

int a,b,c;



cin>>a>>b>>c;

cout<<"n=";cin>>n;

if(a==b || b==c || c==a)

{

if(a==b&&a!=c);



cout<<"bu uchburchak teng yonli";

else if(b==c&&b!=a)

cout<<"bu uchburchak teng yonli";

else if(c==a&&b!=c)

cout<<"bu uchburchak teng yonli";

}

else cout<<"bu uchburchak teng yonli uchburchak teng emas";



return 0;

}

149. a1, a2, …, an haqiqiy sonlar ketma-ketligi berilgan. Uning [c;d] kesmada yotgan elementlarini ko’rsating.

#include

//149-masala @TBCLbot

using namespace std;

int main()

{

int n,c,d;



cout<<"n=";cin>>n;

int a[n];

for(int i=1;i<=n;i++)

cin>>a[i];

cout<<"c=";cin>>c;

cout<<"d=";cin>>d;

for(int i=c;i<=d;i++)

cout<

return 0;

}

150. Butun sonli massivning 9 ga karrali elementlari ko’paytmasini toping.

#include

//150-masala @TBCLbot

using namespace std;

int main()

{

int n;


cout<<"n=";cin>>n;

int a[n];

for(int i=1;i<=n;i++)

cin>>a[i];

for(int i=1;i<=n;i++)

if(a[i]%9==0)

cout<

return 0;

}

151. Berilgan N ta natural sonlardan faqat juftlarini yig’indisini topish dasturing tuzing.

#include

//151masala @TBCLbot

using namespace std;

int main()

{

int n,s=0;



cout<<"n=";cin>>n;

int a[n];

for(int i=1;i<=n;i++)

{

cin>>a[i];



if(a[i]%2==0)s+=a[i];

}

cout<<"s="<

return 0;

}

152. Berilgan N ta natural sonlardan faqat toqlarini yig’indisini topish dasturing tuzing.

#include

//152-masala @TBCLbot

using namespace std;

int main()

{

int n,s=0;



cout<<"n=";cin>>n;

int a[n];

for(int i=1;i<=n;i++)

{

cin>>a[i];



if(a[i]%2!=0)s+=a[i];

}

cout<<"s="<

return 0;

}

153. Ikkita sonning yig’indisini topish funksiyasini yozing va unga murojaat qiling.

#include

//153-masala @TBCLbot

using namespace std;

int SUMMA(int a,int b)

{

return a+b;



}

int main()

{

int a,b;


cout<<"a=";cin>>a;

cout<<"b=";cin>>b;

cout<<"a+b="<

return 0;

}

154. Ikkita sonning ko’paytmasini topish funksiyasini yozing va unga murojaat qiling.

#include

//154-masala @TBCLbot

using namespace std;

int SUMMA(int a,int b)

{

return a*b;



}

int main()

{

int a,b;


cout<<"a=";cin>>a;

cout<<"b=";cin>>b;

cout<<"a*b="<

return 0;

}

155. Ikkita sonning ayirmasini topish funksiyasini yozing va unga murojaat qiling.

#include

//155-masala @TBCLbot

using namespace std;

int SUMMA(int a,int b)

{

return a-b;



}

int main()

{

int a,b;


cout<<"a=";cin>>a;

cout<<"b=";cin>>b;

cout<<"a-b="<

return 0;

}

156. Ikkita sonning bo’linmasini topish funksiyasini yozing va unga murojaat qiling.

#include

//154-masala @TBCLbot

using namespace std;

int SUMMA(int a,int b)

{

return a/b;



}

int main()

{

int a,b;


cout<<"a=";cin>>a;

cout<<"b=";cin>>b;

cout<<"a/b="<

return 0;

}

157. To’g’ri to’rtburchakning tomonlari a va b berilgan. Uning yuzasini aniqlash funksiyasini yozing va unga murojaat qiling.

#include

//157-masala @TBCLbot

using namespace std;

int YUZA(int a,int b)

{

return a*b;



}

int main()

{

int a,b;


cout<<"a=";cin>>a;

cout<<"b=";cin>>b;

cout<<"S="<

return 0;

}

158. Doiraning radiusi berilgan. Uning yuzasini aniqlash funksiyasini yozing va unga murojaat qiling.

#include

//158-masala @TBCLbot

using namespace std;

float YUZA(float r)

{

return r*r*M_PI;



}

int main()

{

float r;


cout<<"r=";cin>>r;

cout<<"S="<

return 0;

}

159. Teng yonli trapetsiyaning a va b asoslari, balandligi berilgan. Uning yuzasini topish funksiyani yozing va unga murojaat qiling.

#include

//159-masala @TBCLbot

using namespace std;

int YUZA(int a,int b,float h)

{

return (a+b)*h*1./2;



}

int main()

{

int a,b;


float h;

cout<<"a=";cin>>a;

cout<<"b=";cin>>b;

cout<<"h=";cin>>h;

cout<<"S="<

return 0;

}

160. Kvadratning tomoni a berilgan. Berilgan kvadratning diametrini topish funksiyasini yozing va unga murojaat qiling.

#include

//160-masala @TBCLbot

using namespace std;

int Radius(int a)

{

return a/2;



}

int main()

{

int a;


cout<<"a=";cin>>a;

cout<<"R="<

return 0;

}

161. Berilgan satrda nechta kichik a harfi qatnashganini aniqlash dasturini tuzing.

#include

//161-masala @TBCLbot

using namespace std;

int main()

{

string a;



int k=0;

cout<<"Satr kiriting:";getline(cin,a);

for(int i=0;i

{

if(a[i]=='a')



k++;

}

cout<<"satrdagi a harflar soni: "<

return 0;

}

162. Berilgan satrda nechta kichik b harfi qatnashganini aniqlash dasturini tuzing.

#include

//162-masala @TBCLbot

using namespace std;

int main()

{

string a;



int k=0;

cout<<"Satr kiriting:";getline(cin,a);

for(int i=0;i

{

if(a[i]=='b')



k++;

}

cout<<"satrdagi b harflar soni: "<

return 0;

}

163. Berilgan satrda nechta vergul, nuqta, so’roq belgisi qatnashganini aniqlash dasturini tuzing.

#include

//163-masala @TBCLbot

using namespace std;

int main()

{

string a;



int k=0,k1=0,k2=0;

cout<<"Satr kiriting:";getline(cin,a);

for(int i=0;i

{

if(a[i]==','||a[i]==’.’||a[i]==’?’)



k++;

}

cout<<"satrdagi vergul,nuqta,so’roqlar soni: "<

return 0;

}

164. Berilgan satrda nechta raqam qatnashganini aniqlash dasturini aniqlang.

#include

//164-masala @TBCLbot

using namespace std;

int main()

{

string a;



int k=0;

cout<<"Satr kiriting:";getline(cin,a);

for(int i=0;i

{

if(48<=a[i]&&a[i]<=57)



k++;

}

cout<<"satrdagi raqamlar soni: "<

return 0;

}

165. Uchta satr berilgan. Bu satrlarni birlashtirish dasturini tuzing.

#include

//165-masala @TBCLbot

using namespace std;

int main()

{

string s,s1,s2,s3;



cout<<"Satr kiriting:s1=";getline(cin,s1);

cout<<"Satr kiriting:s2=";getline(cin,s2);

cout<<"Satr kiriting:s3=";getline(cin,s3);

s=s1+s2+s3;

cout<<"s1,s2,s3 satrlar birlashmasi: "<

return 0;

}

166. Matn berilgan. Bu matnda “lar” qismiy satri necha marta uchrashini aniqlash dasturini tuzing.

#include

//166-masala @TBCLbot

using namespace std;

int main()

{

string s,s1="lar";



int k=0,m=0,n=0;

cout<<"Satr kiriting: ";getline(cin,s);

for(int i=0;i

{

k=s.find(s1,i);



// cout<<"k="<

if(k!=m&&k!=-1)

n++;

m=k;


}

cout<<"\nn="<

return 0;

}

167. „Talaba“ strukturasini yozing va unga boshlang’ich qiymat bering. Uning 4 ta maydoni bo’lsin.

#include

//167-misol

using namespace std;

struct Talaba

{

string ism;



string familiya;

int kurs;

int ball;

};

int main()



{

Talaba a ={"Lazizbek","Karimov",1,5};

return 0;

}

168. „Guruh“ strukturasini yozing va unga boshlang’ich qiymat bering. Uning 4 ta maydoni bo’lsin.

#include

//168-masala @TBCLbot




using namespace std;

struct Guruh

{

string nom;



string shior;

string sardor;

int azo;

};

int main()



{

Guruh a ={"Yingilmas","Kuch Adolatda","Lazizbek",30};

return 0;

}

169. „Mamlakat“ strukturasini yozing va unga boshlang’ich qiymat bering. Uning 3 ta maydoni bo’lsin.

{#include

//169-masala @TBCLbot

using namespace std;

struct Mamlakat

string nom;

int maydon;

int aholi;

};

int main()



{

Mamlakat a ={"O'zbekiston",448921,35000000};

return 0;

}

170. „Kitob“ strukturasini yozing va unga boshlang’ich qiymat bering. Uning 3 ta maydoni bo’lsin

#include

//170-masala @TBCLbot

using namespace std;

struct Kitob

{

string nom;



string molif;

int sahifa;

};

int main()



{

Kitob a ={"O'tgan kunlar","Abdulla Qodiriy",620};

return 0;

}

171. Butun sonli massivning juft elementlari yig’indisini toping.

#include

//171masala @TBCLbot

using namespace std;

int main()

{

int n,s=0;



cout<<"n=";cin>>n;

int a[n];

for(int i=1;i<=n;i++)

{

cin>>a[i];



if(a[i]%2==0)s+=a[i];

}

cout<<"s="<

return 0;

}

172. n ta butun sonlar ketma-ketligini kiriting. Hamma manfiy sonlar yig’indisini toping.

#include

//172-masala @TBCLbot

using namespace std;

int main()

{

int n,s=0;



cout<<"n=";cin>>n;

int a[n];

for(int i=1;i<=n;i++)

{

cin>>a[i];



if(a[i]<0)s+=a[i];

}

cout<<"s="<

return 0;

}

173. n va m natural sonlar berilgan. Ularning eng kichik umumiy karralisini toping.

#include

//173-misol;

using namespace std;

int ekub(int a,int b)

{

while(b)


{

a%=b;


swap(a,b);

}

return a;



}

int main()

{

int a,b,EKUB,EKUK;



cin>>a>>b;

EKUB=ekub(a,b);

EKUK=(a*b)/EKUB;

cout<<"EKUK :="<

return 0;

}

174. 10 dan 40 gacha bo’lgan barcha butun sonlarning kvadratlarini chop etuvchi dastur tuzing.

#include

//174-masala @TBCLbot

using namespace std;

int main()

{

int n=40,s=0;



for(int i=10;i<=n;i++)

{


cout<}

return 0;



}

175. 50 dan 500 gacha bo’lgan barcha butun sonlarning kvadratlarini chop etuvchi dastur tuzing.

#include

//175-masala @TBCLbot

using namespace std;

int main()

{

int n=500,s=0;



for(int i=50;i<=n;i++)

{


cout<}

return 0;



}

176. 101 dan 301 gacha barcha toq sonlar yig’indisini hisoblang.

#include

//176-misol @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=101,s=0;

while(k<301)

{

if(tub(k))



{

S+=k;


}

k++;


}

cout<


return 0;

}

177. XOY tekislikda A nuqta o’zining koordinatalari bilan berilgan. U qayerda joylashganligini ko’rsating (qaysi o’qda yoki qaysi chorakda).

#include

//40-masala

//Muallif:Lazizbek Karimov

//Sana:12.01.2021

using namespace std;

int main()

{

float x,y;



cout <<" a nuqta kordinatalarini kiriting" << endl;

cout<<" x=";cin>>x;

cout<<" y=";cin>>y;

if(x==0&&y==0)cout<<"a nuqta kordinata boshida joylashgan";

else if(x==0&&y!=0)cout<<"a nuqta y o'qida joylashgan";

else if(x!=0&&y==0)cout<<"a nuqta x o'qida joylashgan";

else if(x>0&&y>0) cout<<"a nuqta birinchi chorakda joylashgan";

else if(x<0&&y>0) cout<<"a nuqta ikkinchi chorakda joylashgan";

else if(x<0&&y<0) cout<<"a nuqta uchinchi chorakda joylashgan";

else if(x>0&&y<0) cout<<"a nuqta to'rtinchi chorakda joylashgan";

return 0;

}

178. Ikkita nuqta berilgan: A(x1,y1) va B(x2, y2). Bu nuqtalardan qaysinisi koordina boshiga yaqin joylashganligini aniqlaydigan algoritm tuzing.

#include

#include

using namespace std;

//37-masala

//Muallif:Lazizbek Karimov

//Sana:12.01.2021

int main()

{

float x1,y1,x2,y2,a,b;



cout<<"x1="; cin>>x1;

cout<<"y1="; cin>>y1;

cout<<"x2="; cin>>x2;

cout<<"y2="; cin>>y2;

a=sqrt(x1*x1+y1*y1);

b=sqrt(x2*x2+y2*y2);

if(a>b)

cout<<"A nuqta koordinata boshiga nisbattan yaqinroq joylashgan";

if(a==b)

cout<<"A nuqta ham B nuqta ham koordinata boshiga nisbattan bir xil uzoqlikda joylashgan ";

if(a

cout<<"B nuqta koordinata boshiga nisbatan yaqinroq joylashgan";

return 0;

}

179. Kiritilgan har bir raqam (0-9) uchun, ularga mos ingliz tilidagi nomlarini (0-zero, 1-one, 2-two...) chiqaring.

#include

using namespace std;

//28-masala

//Muallif:Lazizbek Karimov

//Sana:12.01.2021

int main()

{

int K;


cout<<"K=";cin>>K;

switch(K)

{

case 0:cout<<"zero";break;



case 1:cout<<"one";break;

case 2:cout<<"two";break;

case 3:cout<<"three";break;

case 4:cout<<"four";break;

case 5:cout<<"five";break;

case 6:cout<<"sex";break;

case 7:cout<<"seven";break;

case 8:cout<<"eight";break;

case 9:cout<<"nine";break;

default:cout<<"(0-9) oralig‘idagi musbat butun sonlarni kiriting!!";

}

return 0;



}

180. Uchta turli xil sonlarning maksimal va minimal qiymatlarini aniqlang.

#include

//180-masala @TBCLbot

using namespace std;

int main()

{

int a,b,c;



cin>>a>>b>>c;

cout<<"max="<

cout<<"min="<

return 0;

}

181. Berilgan satrdagi dastlabki 4 ta so’zdan yangi satr hosil qiling.

182. Berilgan ikkita satrlarni birlashtirish dasturini tuzing.

#include

//182-masala @TBCLbot

using namespace std;

int main()

{

string s,s1,s2;



cout<<"Satr kiriting:s1=";getline(cin,s1);

cout<<"Satr kiriting:s2=";getline(cin,s2);

s=s1+s2;

cout<<"s1,s2satrlar birlashmasi: "<

return 0;

}

183. Uch xonali son berilgan. Jumlani rostlikka tekshiring: „Ushbu sonning barcha raqamlari har xil”.

#include

//183-misol;@TBCLbot

using namespace std;

int main()

{

int n1,n2,n3;



n1=n/100;

n2=(n/10)%10;

n3=n%10;

if(n1!=n2&&n2!=n3&&n1!=n3)

cout<<"Rost";

else cout<<”Yolg’on”;

}

return 0;



}

184. Aylananing uzunligi C ma’lum. Ushbu aylanaga ichki chizilgan kvadratning perimetrini topish dasturini tuzing.

#include

//184-masala @TBCLbot

using namespace std;

int main()

{

float C,a=0;



cout<<"C=";cin>>C;

a=2*sqrt(2)*C*1./M_PI;

cout<<"Kvadrat Perimetri:"<<4*a;

return 0;

}

185. Berilgan son uchun uning hamma bo’luvchilarini toping va natijani faylga yozing.

#include

//185-masala @TBCLbot

using namespace std;

int main()

{

//Ma'lumot qo'shish uchun ochish



ofstream file("d:\\Buluvchilar.txt",ios_base::app);

//Fayl mavjud yoki mavjud emasligini aniqlash

if(file.is_open())

{

int a,i=1;



cout<<" Fayl yaratildi!\n";

cout<<" a=";cin>>a;

//a soning bo'luvchilarini topish

file<<" a="<

while(a!=i)

{

if(a%i==0)



{

cout<<" "<

file<

}

i++;



}

//Faylga yozish

file<

}

//Fayil mavjud emasligini chop etish



else

{

cout << "Fayl topilmadi";



cin.get();

return -1;

}

return 0;



}

186. N ta son berilgan bu sonlarning yig’indisini faylga yozing.

#include

//186-masala @TBCLbot

using namespace std;

int main()

{

//Ma'lumot qo'shish uchun ochish



ofstream file("d:\\Buluvchilar.txt",ios_base::app);

//Fayl mavjud yoki mavjud emasligini aniqlash

if(file.is_open())

{

int n,i=1,S=0,m;



cout<<" Fayl yaratildi!\n";

cout<<" n=";cin>>n;

//n ta soning yig’indisini topish

for(int i=1;i<=n;i++)

{

cin>>m;


S+=m;

}

file<

}

//Faylga yozish

file<

}

//Fayil mavjud emasligini chop etish



else

{

cout << "Fayl topilmadi";



cin.get();

return -1;

}

return 0;



}

187. N ta son berilgan bu sonlardan eng kattasini faylga yozing.

#include

//187-masala @TBCLbot

using namespace std;

int main()

{

//Ma'lumot qo'shish uchun ochish



ofstream file("d:\\Buluvchilar.txt",ios_base::app);

//Fayl mavjud yoki mavjud emasligini aniqlash

if(file.is_open())

{

int n,i=1,S,m;



cout<<" Fayl yaratildi!\n";

cout<<" n=";cin>>n;

cin>>m;

S=m;


for(int i=1;i<=n;i++)

{

cin>>m;



if(S>m)S=m;

}

file<

}

//Faylga yozish

file<

}

//Fayil mavjud emasligini chop etish



else

{

cout << "Fayl topilmadi";



cin.get();

return -1;

}

return 0;



}

188. N ta son faylga yozilgan. Bu fayldan ma’lumotlarni o’qib, barcha sonlarning yig’indisini chop eting.

#include

//188-masala @TBCLbot

using namespace std;

int main()

{

ifstream files;



files.open("d:\Bugun.txt");

//fileni ochish

int a,S=0;

if(files.is_open())

{

//file ochilganligini aniqlash



cout<<" Fayl yaratildi!\n";

while(!files.eof())

{

//fileni oxirigacha o'qish



files >> a ;

S+=a;


//filega yozish

}

cout<<"S="<

}

else


{

cout<<" Fayl topilmadi!";

cin.get();

return -1;

}

return 0;



}

189. N natural son berilgan. Berilgan natural sonning raqamlarini yig’indisini aniqlash funksiyasini yozing va unga murojaat qiling.

#include

//189-masala @TBCLbot

using namespace std;

int SUMMA(int n)

{

int s=0,k;



while(n)

{

k=n%10;



s+=k;

n/=10;


}

return s;

}

int main()



{

int n;


cin>>n;

cout<

return 0;

}

190. N natural son berilgan. Berilgan natural sonning toq yoki juftligini aniqlash funksiyasini tuzing va unga murojaat qiling.

#include

//190-masala @TBCLbot

using namespace std;

bool Son(int n)

{

if(n%2==0)



return 1;

else return 0;

}

int main()



{

int n;


cin>>n;

if(Son(n))

cout<<"Berilgan son juft son";

else


cout<<"Berilgan son toq son";

return 0;

}

191. N natural son berilgan. Berilgan natural sonning 3 ga karrali ekanligini aniqlash funksiyasini tuzing va unga murojaat qiling.

#include

//191-masala @TBCLbot

using namespace std;

bool Son(int n)

{

if(n%3==0)



return 1;

else return 0;

}

int main()



{

int n;


cin>>n;

if(Son(n))

cout<<"Berilgan 3 ga karrali";

else


cout<<"Berilgan 3 ga karrali emas";

return 0;

}

192. N natural son berilgan. Uning oxirgi raqamini aniqlash funksiyasini tuzing va unga murojaat qiling.

#include

//192-masala @TBCLbot

using namespace std;

int Son(int n)

{

return n%10;



}

int main()

{

int n;


cin>>n;

cout<<"Berilgan sonoing oxirgi raqami: "<

return 0;

}

193. M va N butun sonlari berilgan. ifodani hisoblash funksiyasini yozing va unga murojaat qiling.

#include

//193-masala @TBCLbot

using namespace std;

float Son(int n,int m)

{

float k;


k=(m+n)*1./(2*m*n);

return k;

}

int main()



{

int n,m;


cout<<"M=";cin>>n;

cout<<"N=";cin>>m;

cout<<"Ifodaning qiymati: "<

return 0;

}

194. M va N butun sonlari berilgan. ifodani hisoblash funksiyasini yozing va unga murojaat qiling.

#include

//194-masala @TBCLbot

using namespace std;

float Son(int n,int m)

{

float k;



k=(m*m+2*n)*1./(m*n);

return k;

}

int main()



{

int n,m;


cout<<"M=";cin>>n;

cout<<"N=";cin>>m;

cout<<"Ifodaning qiymati: "<

return 0;

}

195. N natural son berilgan. Berilgan natural sonning K ga karrali ekanligini aniqlash funksiyasini tuzing va unga murojaat qiling.

#include

//195-masala @TBCLbot

using namespace std;

bool Son(int n,int k)

{

if(n%k==0)



return 1;

else return 0;

}

int main()



{

int n,k;


cout<<"n=";cin>>n;

cout<<"k=";cin>>k;

if(Son(n,k))

cout<<"Karrali";

else cout<<"Karrali emas";

return 0;

}

196. 10 dan 1000 gacha bo’lgan barcha butun sonlarning kublarini chop etuvchi dastur tuzing.

#include

//196-masala @TBCLbot

using namespace std;

int main()

{

for(int i=10;i<=1000;i++)



cout<

return 0;

}

197. S1 va S2 lar berilgan. Bu ikki satrning uzunliklarini qo’shish dasturing tuzing.

#include

//197-masala @TBCLbot

using namespace std;

int main()

{

string s1,s2;



int k;

cout<<"Satr kiriting:s1=";getline(cin,s1);

cout<<"Satr kiriting:s2=";getline(cin,s2);

k=s1.size()+s2.size();

cout<<"s1,s2satrlar uzunliklari yig’indisi: "<

return 0;

}

198. a1,a2,… ,an haqiqiy sonlar berilgan. Eng katta va eng kichik elementlarini toping va quyidagi ifodani hisoblang . Bu yerda eng katta son, eng kichik son .

#include

//198-masala @TBCLbot

using namespace std;

int main()

{

int m,max1,min1,n;



cout<<"n=";cin>>n;

cin>>m;


max1=m;

min1=m;


for(int i=1;i{

cin>>m;



if(m>max1)max1=m;

if(m

}

cout<<2*max1+3*min1;



return 0;

}

199. Uchburchakning tomonlari berilgan: a,b,c. Bu tomonlarga uchburchakning balandligini aniqlash funksiyasini yozing va unga murojaat qiling.

#include

//118-masala @TBCLbot

using namespace std;

float balandlik(float&a1,float&b,float&c)

{

float s,p;



p=(a1+b+c)*1./2;

s=sqrt(p*(p-a1)*(p-b)*(p-c));

a1=2*s*1./a1;

b=2*s*1./b;

c=2*s*1./c;

return 0;

}

int main()



{

float a1,b,c;

cout<<"uchburchak tomonlari:";cin>>a1>>b>>c;

balandlik(a1,b,c);

cout<<"ha="<>a>>b>>c;

mediana(a,b,c);

cout<<"ma="<Download 265,24 Kb.
Do'stlaringiz bilan baham:

1   ...   58   59   60   61   62   63   64   65   66




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

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish