linkedin facebook linkedin facebook nod32

C++ tilida Siklik algoritmlarni dasturlash

Muallif: Mengliyev Sh.

Qo`shilgan sana: 2014-10-27

C++ tilida Siklik (Tokrorlanuvchi) algoritmlarni dasturlash

3.1- masala. Y=X2 ning [0,1] oraliqda 0,1 qadam bilan qiymatlar jadvalini aniqlang.
C++  da dasturu:
#include<iostream.h>                                                                                                      

Int main()
{
float a,b,x,y,h;
cout<<”a=”;cin>>xa;
cout<<”b=”;cin>>b;
cout<<”h=”;cin>>h;
x=a;
do
{y=x*x;
cout <<"x=" <<x;
cout <<"y=" <<y;
x=x+h;
}
while(x<=b);
}

3.2- masala. N! Aniqlansin. Bunda N natural son.

C++ da dasturu:
#include<iostream.h>                                                                                                     

  Int main()
{
int i,n;
int p;
cout<<”n=”;cin>>n;
p=1;
for(i=1;i<=n;i++)
{
p=p*i
};
cout <<"p=" <<p;
system("PAUSE");
return 0;
}

3.3- masala. 1dan 20 gacha natural sonlar kvadratlari yig’indisini toping.

C++ da dasturu:
#include<iostream.h>                                                                                                  

     Int main()
{
int i,n;
int s;
cout<<”n=”;cin>>n;
s=0;
for(i=1;i<=n;i++)
{
s=s+i*i;
};
cout <<"s=" <<s;
system("PAUSE");
return 0;
}

3.4- masala. A sonining N darajasini takrorlash buyrug’i yordamida hisoblang.
Yechish. A sonning n – darajasiga teng kattalikni  y bilan belgilaymiz.

C++  da dasturu:
#include<iostream.h>                                                                                                     

  Int main()
{
int i,n,a;
int y;
cout<<”a=”;cin>>a;
cout<<”n=”;cin>>n;
y=1;
for(i=1;i<=n;i++)
y=y*a;
cout <<"y=" <<;
system("PAUSE");
return 0;
}
3.5-masala. 1 dan 10 gacha bo’lgan sonlardan sikl qadami 1 ga teng holda kvadrat ildiz chiqaring.
Yechish. Berilgan x sondan chiqarilgan kvadrat ildizning qiymatini y bilan belgilaymiz. y=x2

C++  da dasturu:
#include<iostream.h>
#include<math.h>                                                                                                       

Int main()
{
int a,b,i;
float y;
cout<<”a=”;cin>>a;
cout<<”b=”;cin>>b;
for(i=a;i<=b;i++)
{
y=sqr(i);
cout <<"i=" <<i;
cout <<"y=" <<y;
};
system("PAUSE");
return 0;
}
3.6-masala. 1 dan 9 gacha bo’lgan sonlarni ko’paytirish jadvalini ekranga chiqaring.
Yechish. Bu masalani yechish uchun 3 marta sikl buyrug’idan foydalanamiz. Birinchi siklda birinchi ko’paytuvchi 1 dan 3 gacha, ikkinchisi esa, 1 dan 9 gacha o’zgaradi.  Ikkinchisi siklda birinchi ko’paytuvchi 4 dan 6 gacha, ikkinchisi esa, 1 dan 9 gacha o’zgaradi.  Uchinchi siklda birinchi ko’paytuvchi 7  dan 9 gacha, ikkinchisi esa, 1 dan 9 gacha o’zgaradi. 

C++ da dasturu:
#include<iostream.h>                                                                                                      

 Int main()
{
int a,b,i,j;
int y;
cout<<”a=”;cin>>a;
cout<<”b=”;cin>>b;
for(i=a;i<=b;i++)
{
for(j=1;j<=10;j++)
{
y=i*j;
}
cout <<"i*j=" <<y;
}
system("PAUSE");
return 0;
}
3.7-masala. L nomerli Fibonachchi sonini ekranga chiqaring. Yechish.  1,1,2,3,5,8,13,21,34,...sonlar  Fibonachchi sonlar ketma-ketligini ifodalaydi. Bu sonlar ketma-ketligida  uchinchi hadidan boshlab har bir son o’zidan oldingi ikkita sonning yig’indisiga teng.

C++ da dasturu:
#include<iostream.h>                                                                                                      

Int main()
{
int i,w,v,r,n;
w=0; v=1; i=1;
cout<<”n=”;cin>>n;
while (i<n)
{
r=w+v; w=v; v=r;
i=i+1;
};
cout <<"v=" <<v;
system("PAUSE");
return 0;
}

3.8-masala. Natural sonni tub ko’paytuvchilarga ajrating.

C++ da dasturu:
#include<iostream.h>
#include<math.h>                                                                                                        

Int main()
{
int n,i,a;
cout<<”n=”;cin>>n;
for (i=1;i<=n;i++)
{
a=n%i;
if ((n % i)=0)
{
cout <<"i=" <<i;
Memo1->Lines->Add(IntToStr(i));
}

}
system("PAUSE");
return 0;

}

3.9-masala. N natural son va A haqiqiy son berilgan. Quyidagi ko’paytmani hisoblang.

C++ da dasturu:
#include<iostream.h>                                                                                                      

Int main()
{
int n,i;
float a,p;
cout<<”n=”;cin>>n;
cout<<”a=”;cin>>a;
p=1;
for (i=0; i<=n; i++)
p=p*(a+i);
cout <<"p=" <<p;
system("PAUSE");
return 0;
}

1130 marta o`qildi.

Foydalanuvchi ismi: Boltayev A.X.
Qo`shilgan sana: 2014-12-26

Talabalar uchun yaxshi namuna. javob: Bunday misollar menda ko`p faqat yoshlarning harakatiga bo`g`liq mendan va sizdan kuchli yoshlarni doim xurmat qilaman va tazim qilaman

Parol:
Eslab qolish.


Ro`yhatdan o`tish

testing

+998915878681

Siz o`z maxsulotingizni 3D reklama ko`rinishda bo`lishini xohlaysizmi? Unda xamkorlik qilamiz.

3D Reklama


Рейтинг@Mail.ru
Рейтинг@Mail.ru

Besucherzahler
счетчик посещений