1 masala (Ishorani aniqlang). Foydalanuvchi tomonidan butun son kiritilganda, mazkur son manfiy yoki musbat son ekanligini chop etuvchi dastur tuzing


Download 25.41 Kb.
Sana13.01.2023
Hajmi25.41 Kb.
#1091829
Bog'liq
Dasturlash I 1-mustaqil ish


1 masala (Ishorani aniqlang). Foydalanuvchi tomonidan butun son kiritilganda, mazkur son manfiy yoki musbat son ekanligini chop etuvchi dastur tuzing. (Algoritm blok-sxemasi va dastur kodi tuzilishi va natija chop etilishi shart).

#include


using namespace std;


int main()


{
int min, max, n, number;

cout<<"n="; cin>>n;//sonlar miqdori 5


cout <<"1=son:"; cin>> number;//3

min = number; max = number; //min:3 max:3


for(int i=0; i
cout<< i+2 << "son:"; cin>>number; //1, 9

if(number
min = number;//1
if(numbermax = number;
}

cout<<"Min:"<
cout<<"Max:"<

system("pause");


return 0;
}
2 masala (Algebra: Kvadrat tenglamani hisoblang). Kvadrat tenglamaning ax2 + bx + c = 0 ildizlarini toping:

#include


#include
#include

using namespace std;


int main()


{
float a, b, c, d, e;
cout <<"Kvadrat tenglamaning hadlarini kiriting\n ax^2+bx+c=0\n";
cout <<"a sonni kiriting="; cin>>a;
cout <<"b sonni kiriting="; cin>>b;
cout <<"c sonni kiriting="; cin>>c;
d=(-b+(sqrt(b*b-4*a*c)))/(2*a);
e=(-b-(sqrt(b*b-4*a*c)))/(2*a);
cout <<"Kvadrat tenglamaning birinchi ildizi=" << d << endl;
cout <<" Kvadrat tenglamaning ikkinchi ildizi=" << e << endl;
return 0;
}

3 masala (Koordinata) OX va OY koordinata o'qlarida yotmaydigan nuqta berilgan. Nuqta joylashgan koordinata choragi aniqlansin.


#include


#include
using namespace std;

int main()


{
float a,b,c,x1,x2;
cout<< "ax^2+bx+c=0\n";
cout<<"a= ";
cin>>a;
cout<<"b= ";
cin>>b;
cout<<"c= ";
cin>>c;
x1=(-b+(sqrt(b*b-4*a*c)))/(2*a);
x2=(-b-(sqrt(b*b-4*a*c)))/(2*a);
cout<cout<return 0;
}
4 masala 4 xonali son berilgan .Uning raqamlarini teskariga yozish dasturini tuzish lozim.

#include


using namespace std;


int main()


{
int son, teskari=0;
cout << "Sonni kiriting >>>"; cin>>son;

while (son>0)


{
teskari = teskari * 10 + son % 10;
son/=10;
}
cout <<"Sonning teskarisi >>>>" <return 0;

}
5 masala. (Sanoq sistemasi). O‘nlik sanoq sistemasida berilgan son ikkilik sanoq sistemasiga o‘tkazilsin. 0<=n<=100


#include


#include
using namespace std;
int main ()
{
int a,b=0,c=0;
cin>>a;
while(a>0){
b=b*10+a%2;
a/=2;
}
while(b>0){
c=c*10+b%10;
b/=10;
}
cout<return 0;
}

Download 25.41 Kb.

Do'stlaringiz bilan baham:




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