Nazariy qism(1-90) Massivlarni saralash algoritmlari


fillpoly (int numpoints, int * polypoints)



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

fillpoly (int numpoints, int * polypoints); - Funktsiya belgilangan rangga ega ko'pburchakni chizadi va bo'yaydi.

setcolor (int color); - Rangni rang o'zgaruvchisi tomonidan berilgan raqam bilan belgilaydi.

MASALALAR (91-200)

91. 20 dan 500 gacha sonlar orasida nechta son 5 ga qoldiqsiz bo’linishini aniqlash dasturini tuzing

#include

using namespace std;

//91-misol @TBCLbot

int main()

{

int s=0;



for(int i=20;i<=500;i++)

{

if(i%5==0)



s++;

}

cout<

return 0;

}

*************************************



92. Manfiy bo’lmagan butun son berilgan. Uning oxirgi raqamini aniqlash dasturini tuzing

#include

//92-misol;

using namespace std;

int main()

{

int n,n1;



cout<<"musbat son kiriting :=";

cin>>n;


n1=n%10;

cout<<"Berilgan son oxirgi raqami : "<

return 0;

}

93. S=1+2+3+…+n yig’indini hisoblash dasturini tuzing.

#include

//93-misol @TBCLbot

using namespace std;

int main()

{

int n,s=0;



cout<<"n sonni kiriting :=";

cin>>n;


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

{

s=s+i;



}

cout<<"yig`indi : "<

return 0;

}

94. A[n] massiv berilgan. Bu massivning barcha elementlari yig’indisini toping.

#include

//94-misol;

using namespace std;

int main()

{

int n,s=0;



cout<<"massiv elementlari sonini kiriting :"<

cin>>n;


int a[n];

srand(time(NULL));

for(int i=0;i

{

a[i]=rand()%10;



cout<

s=s+a[i];

}

cout<<"massiv elementlari yig`indisi :"<

return 0;

}

95. A[n] massiv berilgan. Bu massivning barcha elementlari ko’paytmasini topish dasturini tuzing

#include

//95-misol @TBCLbot

using namespace std;

int main()

{

int n,s=1;



cout<<"massiv elementlari sonini kiriting :"<

cin>>n;


int a[n];

srand(time(NULL));

for(int i=0;i

{

a[i]=rand()%10;



cout<

s=s*a[i];

}

cout<<"massiv elementlari yig`indisi :"<

return 0;

}

96. A[n] massiv berilgan. Bu massivning uchga karrali elementlarini chop etish dasturini tuzing.

#include

//96-misol @TBCLbot

using namespace std;

int main()

{

int n,s=1;



cout<<"massiv elementlari sonini kiriting :"<

cin>>n;


int a[n];

srand(time(NULL));

for(int i=0;i

{

a[i]=rand()%10;



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

cout<

}

return 0;



}

97. B[n] massiv berilgan. Bu massivning hamma manfiy elementlari nechta ekanligini aniqlash dasturini tuzing

#include

//97-misol; @TBCLbot

using namespace std;

int main()

{

int n,s=1;



cout<<"massiv elementlari sonini kiriting :"<

cin>>n;


int B[n];

srand(time(NULL));

for(int i=0;i

{

B[i]=rand()%10;



if(i%4==0)

B[i]*=-1;

if(B[i]<0)

cout<

}

return 0;



}

98. -50 dan katta va 200 dan kichik oraliqdagi, 3 va 4 ga karrali butun sonlarning yig’indisini toping.

#include



//98-misol;@TBCLbot

using namespace std;

int main()

{

int s=0;



for(int i=-50;i<=200;i++)

{

if(i%12==0)



s+=i;

}

cout<<"3 va 4 ga karrali sonlar yig`indisi :"<

return 0;

}

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

#include

//99-misol; @TBCLbot

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;

}

100. Natural n sonini faktorialini hisoblash uchun dastur tuzing (n sonining faktoriali 1*2*…*n ga teng bo’ladi).



#include

//100-misol; @TBCLbot

using namespace std;

int main()

{

int n,s=1;



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

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

{

s=s*i;


}

cout<<"n!= "<

return 0;

}

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

#include

//101-misol; @TBCLbot

using namespace std;

int main()

{

int s=0;


for(int i=101;i<301;i=i+2)

{

s=s+i;



cout<

}

cout<<"toq sonlar yig`indisi"<

cout<<"101+...+301= "<

return 0;

}

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

#include

//102-misol; @TBCLbot

using namespace std;

int main()

{

int a[]={0};



int n,s=0;

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

for(int i=0;i

{

cout<<"A["<

cin>>a[i];

}

for(int i=0;i

{

if(a[i]<0)

s+=a[i];

}

cout<<"s="<

return 0;

}

103. n ta sondan eng kattasini topuvchi dasturni tuzing.



#include

//103-misol; @TBCLbot

using namespace std;

int main()

{

int n,a,k=0,max1;



cin>>n;

cin>>a;


max1=a;

for(int i=1;i

{

cin>>a;


if(a>max1)max1=a;

}

cout<<"n ta son ichidagi eng kattasi: "<

return 0;

}

104. Barcha uch xonali tub sonlar topilsin. Ularning barchasini va umumiy sonini chop eting.

#include

//104-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=100;

while(k<999)

{

if(tub(k))



{

cout<

}

k++;


}

return 0;

}

105. 100 ta birinchi tub son topilsin.
#include

//105-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=1;


while(k<100)

{

if(tub(k))



{

cout<

}

k++;


}

return 0;

}

106. Sonli yozuvida bir xil raqamlari bo’lmagan barcha uch xonali sonlarni o’sish tartibida chop qiling.

#include

//105-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;



}

107. a1, a2, a3, … , a20 butun sonlar ketma-ketligi berilgan. Ketma-ketlikning barcha elementlari o’zaro teng bo’ladimi?

#include

//107-misol; @TBCLbot

using namespace std;

int main()

{

int a[20],k=0;



for(int i=0;i<20;i++)

{

cin>>a[i];



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

//cout<

k++;

}

if(k==20)



cout<<"ketma ket sonlar o`zaro reng";

else cout<<"teng emas";

return 0;

}

108. Berilgan matnda nechta so’z mavjudligini aniqlash dasturini tuzing.

#include

//108-misol; @TBCLbot

using namespace std;

int main()

{

char a[128] = "";



cout << "Istalgan matnni kiriting:\n";

cin.getline(a, 128);

cout <<"Satr "<

return 0;

}

109. Berilgan ikkita satrlarni birlashtirish dasturing tuzing

#include

//109-misol; @TBCLbot

using namespace std;

int main()

{

char someText1[20] = "www.";



char someText2[] = "samdu.uz";

cout << "Birinchi satr: " << someText1 <

cout << "Ikkinchi satr:" << someText2 <

int count1 = 0;

while (someText1[count1] != 0)

{

count1++;



}

int count2 = 0;

while (someText2[count2] != 0)

{


someText1[count1] = someText2[count2];

count1++;

count2++;

}

cout << "Birlashtirilgan satr:" << someText1 << endl;



return 0;

}

110. Berilgan satrning uzunligini va xotira hajmini aniqlang.

#include

#include

using namespace std;

int main()

{

string myString;



//110-savol; @TBCLbot

cout << "Ismingiz nima? ";

getline(cin, myString);

cout << "Satr, " << myString << "! \n";

cout << "Satr uzunligi: " << myString.size() << "\n";

cout << "Satr hajmi: " <

}

111. S1 va S2 lar berilgan. Bu ikki satrning uzunliklarini taqqoslang.

#include

#include

using namespace std;

//111-savol;

int main()

{

string s1="matematika";



string s2="fizika";

if(s1.size()>s2.size())

cout<<"s1 satr s2 satrdan uzun";

else if(s2.size()>s1.size())

cout<<"s2 satr s1 satrdan uzun";

else if(s1.size()==s2.size())

cout<<"ikkita satr teng";

return 0;

}

112. a va b sonlardan eng kattasini topishni funksiya yordamida hal eting.

#include

#include

using namespace std;

//112-savol; @TBCLbot

int katta(int a,int b)

{

if(a>=b)


return a;

else return b;

}

int main()



{

int a,b;


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

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

cout<<"katta son " <

return 0;

}

113. Tub sonlarni aniqlashga imkon beruvchi funksiyani aniqlab, barcha uch xonali tub sonlarni aniqlang.

#include

//113-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=100;

while(k<999)

{

if(tub(k))



{

cout<

}

k++;


}

return 0;

}

114. Ikkita uchburchakning tomonlari berilgan. Uning tomonlariga ko’ra uchburchak yuzasini va perimetrlarini hisoblash uchun funksiyani aniqlab, ularning yuzalarini va perimetrlarini yig’indisini toping.

#include

//114-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,a1,b1,c1,p,s;

cout<<"1-uchburchak tomonlari"<

cin>>a>>b>>c;

cout<<"2-uchburchak tomonlari"<

cin>>a1>>b1>>c1;

cout<

cout<



cout<cout<



return 0;

}


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