1-misol(otaxonov 5)
Uchta natural son berilgan. Ularning eng katta umumiy bo‘luvchsini toping.( Ikkita natural sonning EKUB ini topish protsedurasidan foydalaning.)
#include
#include
using namespace std;
int ekub(int a, int b){
while(a!=0){
b=b%a;
int t; t=a; a=b; b=t;
}return b;
}
int main()
{
int a,b,c,x;
cout<<"a="; cin>>a;
cout<<"b="; cin>>b;
cout<<"c="; cin>>c;
x=a*b/ekub(a,b);
cout<
return 0;
}
2-misol(otaxonov 6)
a, b, c va d haqiqiy sonlar berilgan. Bu kesmalarning qaysi uchliklaridan uchburchak tashkil qilish mumkin. Ana shunday uchburchaklarning yuzalarini hisoblang. (Uzunliklari x, y va z bo‘lgan kesmalardan yasash mumkin bo‘lgan uchburchak yuzini topish protsedurasidan foydalaning.)
#include
#include
using namespace std;
float yuza(int a,int b,int c)
{ float p,s;
p=(a+b+c)*1./2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
return s;}
int main()
{ int x,y,z,d;
float k,g,f,m,n,l; cin>>x>>y>>z>>d;
if((x+y)>z&&(x+z)>y&&(y+z)>x)
{k=yuza(x,y,z); cout<if((x+y)>d&&(x+d)>y&&(y+d)>x)
{g=yuza(x,y,d); cout<if((x+z)>d&&(x+d)>z&&(z+d)>x)
{f=yuza(x,z,d); cout<if((z+y)>d&&(z+d)>y&&(y+d)>z)
{m=yuza(z,y,d); cout<return 0;
3-misol(otaxonov 7)
n natural soni hamda a1, a2, ..., an va b1, b2, ..., bn haqiqiy sonlar ketma-ketligi berilgan bo‘lsin. Bu ketma-ketliklarning eng katta elementlaridan ( agar shunday elementlar ko‘p bo‘lsa, tartib bo‘yicha birinchisidan) keyingi barcha elementlarni 0,5 soni bilan almashtiring.
#include
#include
using namespace std;
double massiv(n){int n;cin>>n;
double max,k,b[n];
for(int i=0; i>b[i];
max=b[0];
for(int i=0; i
for(int i=0; i
k=i;
break; }
for(int i=k+1; i
for(int i=0; i
}
int main()
{int n;
massiv(n);
return 0;
}
4-misol (otaxonov9)
#include
#include
using namespace std;
int qisqartma(int &x, int &y){
int a=x,b=y;
while(x){
y=y%x;
int t; t=x; x=y; y=t;
}
x=a/(y);
y=b/(y);
}
int main()
{
int a,b,n[8],d[8];
double s=0;
cout<<"a="; cin>>a;
cout<<"b="; cin>>b;
for(int i=0; i<8; i++ )
{cout<<"n["<>n[i];
cout<<"d["<>d[i];
}
for(int i=7; i>=0; i-- ){
qisqartma(n[i],d[i]);
a=pow(a,i);
b=pow(b,i);
qisqartma(a,b);
s=s+n[i]*1./d[i]*a*1./b;
}cout<
return 0;
}
5-misol(otaxonov 11)
n natural soni hamda a1, a2, ..., an butun sonlar berilgan bo‘lsin. Bu ketma- ketlikning tub sonlardan iborat bo‘lgan eng uzun qismini aniqlang. ( Butun sonning tub yoki tub emasligini aniqlash protsedurasidan foydalaning.)
#include
#include
using namespace std;
int tub(int n )
{
for(int i=2; i<=sqrt(n); i++)
if(n%i==0)
return 0;
}
int main()
{
int n, s=0, k=0;
cin>>n;
int a[n];
for(int i=1; i<=n; i++ )
{
cin>>a[i];
if(tub(a[i])) s++;
else{
if(kcout<return 0;
}
6-misol(otaxonov16)
n natural soni berilgan bo‘lsin. n, n+1, ..., 2n sonlari orasidagi egizak tub sonlarni aniqlang. (Natural sonni tub yoki tub emasligini tekshirish protsedurasidan foydalaning.)
#include
#include
using namespace std;
int tublik(int n){
for(int i=2;i<=sqrt(n);i++)
if(n%i==0) return 0;
return 1;}
int main()
{int n;cin >> n;
for(int i=n; i<=2*n-2; i++)
if(tublik(i)&&tublik(i+2))
{cout<return 0;}
Do'stlaringiz bilan baham: |