38.Uch xonali son berilgan. Uning o‘ng tomonidagi 1-raqami olinib, chap tomonidan joylashtirilsin va hosil bo’lgan son chop etilsin
#include using namespace std; int main()
{
cout<<"3 xonali son kiriting: "; int son;
cin>>son; son=(son%10)*100+son/10; cout<return 0;
}
|
39.n butun soni berilgan
1,11,2 1.3 ...1, n(n ta
ko‘paytuvchi). Ko‘paytma hisoblansin
#include using namespace std; int main()
{
cout<<"n butun sonni kiritig: "; int n;
cin>>n; double k=1;
for(float i=1.1f; (int)(i*10)%10<=n; i+=0.1){
k*=i;
}
cout<}
|
40 Berilgan funksiyani dasturini tuzing
#include #include using namespace std; int main()
{
cout<<"x ning qiymatini kiriting: "; int x;
cin>>x; if(x<=0)
x=-1*x; else if(x<2)
x=pow(x,2); else
x=4;
cout<<"f(x)="<}
|
37. n o‘lchamli, butun sonli massiv berilgan. Berilgan massivdagi barcha toq sonlarni o‘z ichiga oladigan elementlarni o‘sish tartibida tartiblab, chop etilsin hamda ularning miqdori k aniqlansin
#include #include using namespace std; int main()
{
int mas[17]={1,2,3,9,5,56,43,23,45,56,75,34,23
,12,45,67,8};
int length=sizeof(mas)/sizeof(*mas); sort(mas, mas+length);
int k=0;
cout<<"Toq sonlari: "; for(int i=0; iif(mas[i]%2==1){ cout<}
cout<<"\nk="<}
|
94 . Uch xonali son berilgan, uning raqamlari yig‘indisi chop etilsin
x = int(input('Uch xonali sonni kiriting = '))
a = x//100 + x//10%10 + x%100%10
print(a)
|
95. a va b butun sonlar berilgan(a>b). a va b sonlari orasidagi sonlarni o‘sish tartibida chiqarilsin(a va b sonlari ham kiradi) hamda shu sonlar miqdori (soni) n chiqarilsin
a = int(input('Birinchi sonni kiriting = ')) b = int(input('Ikkinchi sonni kiriting = '))
for i in range(a,b+1): print(i)
print('Soni',b+1-a)
|
96. Berilgan funksiyani dasturini tuzing
A = -2
B = 0.9
x = float(input('x sonni kiriting = ')) if xf1 = (A-x)/(2-x*x)
print('f1 funksiya natijasi = ',f1) elif A<=x and xf2 = x**2-(A+B)*x+A*B print('f2 funksiya natijasi',f2)
else:
f3 = (B-x)/(4-3*x*x)
print('f3 funksiya natijasi = ',f3)
|
92. Berilgan funksiyani dasturini tuzing
A = -2
B = 0.9
x = float(input('x sonni kiriting = ')) if x
f1 = (A-x)/(2-x*x)
print('f1 funksiya natijasi = ',f1) elif A<=x and x
f2 = x**2-(A+B)*x+A*B print('f2 funksiya natijasi',f2)
else:
f3 = (B-x)/(4-3*x*x)
print('f3 funksiya natijasi = ',f3)
|
13-misol n o‘lchamli a massiv berilgan(n- toq son). Massivning toq indeksida turgan elementlari indekslarini kamayish tartibida tartiblab chiqarilsin. an, an-2, an-4, … a1
n = int(input("Toq natural son kiriting: "))
if n>0 and n%2==1: arr = []
# indekslash 0 dan boshlanadi for i in range(n):
number = int(input(f"{i}-indeksdagi sonni kiriting: "))
arr.append(number)
print("Teskari tartibdagi toq indeksdagi sonlar: ")
for i in range(n-2, -1, -2):
print(f"{i}-indeksdagi son: {arr[i]}")
else:
print('Toq natural son kiritilmadi.')
|
14-misol. a va n sonlari berilgan. Bitta sikldan foydalanib a sonining 1 dan n gacha bo‘lgan darajalari chiqarilsin
n = int(input("Natural son kiriting: ")) a = float(input("Biror son kiriting: ")) degree = 1;
for i in range(1, n+1): degree *= a;
print(f"{a} ning {i}-darajasi {degree} ga teng.")
|
15-misol Uchta son berilgan. Ularning ikkita kattasining yig‘indisi chiqarilsin
num1 = float(input("1-sonni kiriting: "))
num2 = float(input("2-sonni kiriting: "))
num3 = float(input("3-sonni kiriting: "))
minimum = min(num1, num2, num3)
result = num1+num2+num3- minimum
print(f"Shu sonlardan 2 ta
kattasining yig'indisi {result} ga teng.")
|
16-misol Berilgan funksiyani dasturini tuzing
x = float(input("x ni kiriting: ")) A = -4
B = 3
f1 = (x*x-A*x)/(1+2*x*x) f2 = x*x-(A+B)+A*B
f3 = (x-B)/(3+4*x*x) if x < A:
y = f1 elif x < B: y = f2
else:
y = f3 print(f"y = {y}")
|
81 n o`lchamli a massiv berilgan. Uning
elementlari yig’indisini hisoblovchi dastur tuzing
#include using namespace std; int main()
{
int a[]={12,1552,156,185,123,152},sum=0;
int size = sizeof(a)/sizeof(a[0]);// massiv o'lchami
for(int i=0;isum = sum+a[i];// yig'indi uchun ishlaydi
}
cout<<"Elemetlar yig'indisi"<}
|
20-masala Berilgan funksiyani
dasturini tuzing: #include #include using namespace std; int main(){
float b=4.17,c=0.04,y; y=pow(c,2)*b+pow(cos(pow(b,c)), 2);
if(y>5)cout<<"1-shartni qanoatlantirayapti va masalaning javobi:"<<3;
else
if(y=5)cout<<"2-shartni qanoatlantirayapti va masalaning javobi:"<
else
cout<<"3-shartni qanoatlantirayapti va masalaning javobi:"<
}
|
|
82 Ikki xonali son berilgan, uning raqamlari o‘rnini almashtirish natijasida hosil bo‘lgan son chop etilsin
#include #include using namespace std;
int main()
{
int son,unlik,birlik; cin>>son;
unlik = floor(son/10); birlik = son%10;
cout<<"Qiymat "<}
|
83. a va b butun sonlar berilgan(a<b). a va b sonlari orasidagi sonlarni kamayish tartibida chiqarilsin(a va b sonlari ham kiradi) hamda shu sonlar miqdori (soni) n chiqarilsin
a = int(input('a sonni kiriting = ')) b = int(input('b sonni kiriting = '))
s = 0
for i in range(a,b+1): s+=1
print(b+1-s) print('Soni',b+1-a)
|
83 a va b butun sonlar berilgan(a<b). a va b sonlari orasidagi sonlarni kamayish tartibida chiqarilsin(a va b sonlari ham kiradi) hamda shu sonlar miqdori (soni) n chiqarilsin
#include #include using namespace std;
int main()
{
int a,b; cin>>a>>b;
if(b>a){cout<<"sonlar kamayish tartibida chiqadi \n";
for(int i=b;i>=a;i--){ cout<<" "<}
}
else cout<<"a katta b dan bunday holatda dastur ishlamaydi";
return 0;
}
|
|
|
|
89. n o`lchamli a massiv berilgan. Uning elementlari kvadratini hisoblovchi dastur tuzing
#include using namespace std; int main()
{
int a[]={12,1552,156,185,123,152};
int size = sizeof(a)/sizeof(a[0]); for(int i=0;icout<}
return 0;
}
|
90 Uch xonali son berilgan, uning oxirgi va o‘rta xonasidagi raqamlari chop etilsin
#include #include using namespace std;
int main()
{
int son,unlik,birlik; cin>>son;
unlik = floor(son/10); unlik = unlik%10; birlik = son%10; cout<<"Oxirgi Raqam
"< cout<<"O'rtadagi Raqam
"< return 0;
}
|
91 k va n (n>0) butun sonlar berilgan. n
marta k soni chiqarilsin
#include #include using namespace std;
int main()
{
int k,n;
cout<<"K soni kiritilsin \n"; cin>>k;
cout<<"N soni kiritilsin \n"; cin>>n;
for(int i=0;i}
|
118. n o‘lchamli a massiv berilgan. Uning elementlari teskari tartibda chiqarilsin
// Massiv elementlarini teskari chiqarish!!! #include
using namespace std; int main()
{
int n;
cout <<"n="; cin >>n; int a[n];
for (int i=0; icout <<"a[" << i+1 << "]=";
cin >> a[i];}
for (int i=n-1; i>=0; i--) {
cout << a[i] << " "; } return 0;
}
|
119.1 Ikki xonali son berilgan, uning raqamlari yig’indisi va ko’paytmasi topilsin
#include using namespace std;
int main()
{
int n,n1,n2; cin >>n; n1=n/10; n2=n%10;
cout << "S="<< n1+n2; return 0;
}
|
119.2 Ikki xonali son berilgan, uning raqamlari yig’indisi va ko’paytmasi topilsin #include
using namespace std;
int main()
{
int n,n1,n2; cin >>n; n1=n/10; n2=n%10;
cout << "S="<< n1*n2; return 0;
}
|
117 Berilgan funksiyani dasturini tuzing
#include using namespace std; int main()
{
int x, fx;
cout << "x="; cin >> x; if((x<2)||(x>2)) {
fx=2*x; } else {
fx=-3*x; }
cout << "f(x)" <}
|
120. k va n (n>0) butun sonlar berilgan. n marta k soni chiqarilsin
#include #include using namespace std;
int main()
{
int k,n;
cout<<"K soni kiritilsin \n"; cin>>k;
cout<<"N soni kiritilsin \n"; cin>>n;
for(int i=0;i cout<
}
return 0;
}
|
84 Berilgan funksiyani dasturini tuzing
#include #include using namespace std; int main()
{
double a,b,A=1.03,B=0.006,x,y,F=0; cout<<"x ni kiriting: ";cin>>x; cout<<"a va b ni kiriting "; cin>>a>>b; y=pow(a,2)*b+4*pow(b,a);
if(y>x){
F = 5*pow(x,2) + 1/pow(tan(3*pow(y,- 3*x)),2);
cout<<"y>x shartidagi qiymat "<
}
else{
if(A==y){
F = log2(abs(x-pow(y,2)*3))+2*x*y; cout<<"y=A shartidagi qiymat"<}else{
if(AF=pow(cos(pow(x,-3*x)),2); cout<<"y>A shartidagi qiymat"<}
}
}
return 0;
|
Do'stlaringiz bilan baham: |