3-laboratoriya 5-topshiriq
Ikkita haqiqiy son berilgan. Birinchi sonni chiqaring, agar u ikkinchisidan katta bo`lsa, aks xolda ikkalasini ham chiqaring.
#include
using namespace std;
int main()
{ float x,y;
cout<<"X="; cin>>x; cout<<"Y="; cin>>y;
if(x>y) cout<
Topshiriq5
#include
#include
#include
using namespace std;
int main()
{ double a,b,c,x,q,z1,z2;
cout<<"a="; cin>>a; cout<<"b="; cin>>b;
cout<<"c="; cin>>c; cout<<"x="; cin>>x;
cout<<"q="; cin>>q; bool f=true;
if(a>c)
{ z1=1.0*(x*x*(2*x+a)+c*c*c)/(a*a-c*c);
printf("1-Natija= %.4f",z1); f=false;
} cout<{ z2=1.0*(2*a*b+sin(a*x*x))/sqrt(a*a+2*q*q);
printf("2-Natija= %.4f",z2); f=false;
} if(f) cout<<"Hech qaysi xolatga tushmadi";}
4-lobaratoriya 5-topshiriq
#include
#include
#include
using namespace std;
int main()
{ double n,x,i=1,s=0;
cout<<"x="; cin>>x;
cout<<"n="; cin>>n;
while(i<=n)
{ s+=1.0*pow(x,i)/i;
i+=1;
} printf("Yig'indi= %.4f",s); }
Topshiriq 5
#include
#include
#include
using namespace std;
int main()
{
double a,b,c,x,h=0.2,y=0;
cout<<"a="; cin>>a;
cout<<"b="; cin>>b;
x=c;
do {
y+=a*a*cos(x)+1.0*sin(x)/2+b*x*x;
x+=h;
} while(x<=b);
printf("Yig'indi= %.4f",y); }
5-amaliyot Topshiriq 1
5.Berilgan sondagi qo‘shni raqamlarining raqamlarining yig‘indisiga teng bo‘lgan
raqamni o‘chirivchi funksiya tuzing.
#include
#include
using namespace std;
int MyFunction(int n)
{
int d=n;
int n1,n2,n3;
n1=n%10;n/=10;
n2=n%10;n/=10;
n3=n%10;
if(n1+n3==n2)
{
return n3*10+n1;
}
else
{
return d;
}
}
int main()
{
int n;
cin>>n;
cout<return 0;
}
Topshiriq 2
5.Arifmetik progressiyani birinchi hadi va ayirmasi berilgan. N ta hadini
yig‘indisini hisoblovchi rekursiv funksiya tuzing.
#include
#include
using namespace std;
double MyFunction(int a1,int d, int n)
{
double x;
x=((2*a1+d*(n-1))/2)*n;
return x;
}
int main()
{
int a1,d,n;
cin>>a1>>d>>n;
cout<}
Topshiriq 3
3.Berilgan a va b sonlarini EKUBini topuvchi funksiya tuzing.
) boyi=int(input(""))
eni=int(input(""))
while boyi!=eni:
if boyi>eni:
boyi=boyi - eni
print(boyi, eni)
continue
else:
eni=eni - boyi
print(boyi, eni)
continue
print(boyi, eni)
6-amaliyot
Topshiriq 5
Bir o`lchamli sonli massiv [k,l] kismda yotmaydigan elementlarining o`rtacha qiymatidan hisoblansin
#include
using namespace std;
int main()
{
int n ; cin >> n ;
float c[n] , t ;
int k,l,i, s=0 ;
for ( int i=1 ; i <= n ; i++ )
{ cin >> c[i] ;}
cin >> k ; cin >> l ;
for ( int i = 1 ; i <= n ; i++ )
{
if ( k > i || i > l ) { s+=c[i] ; }
} t = 1.0 * (s)/( n - (l - k + 1 )) ;
printf("%.2f" , t );
}
7-amaliyot
5-topshiriq
L ta elementi bo`lgan bir indeksli massivdan NхM o’lchamli matritsa hosil qilinsin. yetishmay qolgan elementlari nollar bilan to`ldirilsin.
#include
using namespace std;
int main()
{
int d= 1 , l , n , m ;
cin >> l ;
int a[l+1] ;
for ( int i = 1 ; i <= l ; i++ )
{
cin >> a[i] ;
}
cin >> n >> m ;
int b[n+1][m+1] ;
for ( int i = 1 ; i <= n; i++ )
{
for ( int j = 1 ; j <= m ; j++ )
{
if (d <= l) { b[i][j]=a[d]; }
else {b[i][j]=0 ;}
d++ ; cout << b[i][j] << " ";
}
cout <<"\n";
}
return 0 ;
}
8-amaliyot
5-topshiriq
Sizga uzunligi 500 dan oshmaydigan matn berilgan. Sizni vazifangiz shu matndagi kichik xarflarni kattasiga, katta xarflarni kichigiga aylantirishdan iborat.
include
using namespace std;
int main()
{string s; while(cin>>s)
{for(int i=0;i{
if(s[i]>='A'&&s[i]<='Z')
s[i]=s[i]+32;
else s[i]=s[i]-32;} cout<
9-amaliyot
Dostları ilə paylaş: |