int parta(int n){ if(n%2==0) return n/2; else return (n+1)/2; } int main( ){ int a,b,c; cin>>a>>b>>c; cout<
return 0; }
29-misol: (Vaqtlar oralig'i).Bir sutkadagi ikki vaqt ko'rsatkichlari berilgan. Ikkinchi ko`rsatilgan vaqt birinchi ko`rsatilgan vaqtdan oldin kelmaganligi anniq. Ikki vaqt ko`rsatkichlari oralig'ida necha sekund borligini aniqlang.
Boshlash
Dasturi:
h,m,s,H,M,S
#include a=h*3600+m*60+s; b=H*3600+M*60+S;
int main(){ int h,m,s,H,M,S,a,b;
b-a
cin>>h>>m>>s>>H>>M>>S; a=h*3600+m*60+s;
Tamom
b=H*3600+M*60+S; cout< return 0; } 30-misol:(Minimum va maksimum yig'indi).Beshta musbat butun son berilgan, ulardan to'rttasini ajratib olinganda umumiy yig'indisi bo'lishi mumkin bo'lgan minimum qiymat va maksimum qiymatni aniqlang. Dastur: #include using namespace std; int main (){ long long s=0, mn=1e9, mx=1, x; for (int i=0; i<5;i++){ cin>> x; s+=x; mn=min(mn,x); mx=max(mx,x); } cout << s - mx <<' '< return 0;}
31-misol:Agar y, y=2x*x+5,5t-2, t=x+2 formula bilan berilgan boʻlsa, x ning 4, 5, ..., 28 qiymatlari uchun y ning qiymatini hisoblang.
Boshlash
Dastur:
#include
t=0,y=0,x=4
#include
using namespace std;
x<=28
int main(){
float t=0,y=0,x=4;
Tamom
t=x+2;
y=2*x*x+5.5*t-2
if(x<=28){
t=x+2;
y=2*x*x+5.5*t-2;
y;
x=x+1;
cout<
x=x+1;
cout< }
return 0;
}
32-misol: Kvadrat tenglamaning ildizlarini hisoblash algoritmi Ax*x + Bx + C = 0 shaklidagi kvadrat tenglama uchun barcha haqiqiy ildizlarni toping.
Boshlash
Dasturi:
#include
#include
a,b,c
using namespace std;
int main(){
int a,b,c,d,x,x1,x2;
d=b*b-4*a*c;
cin>>a>>b>>c;
d=b*b-4*a*c;
if(d<0){
d<0
cout<<"ildiz yoq";
}
else if(d=0){
x=-b/(2*a);
d=0
Ildiz yo’q
cout< }
else{
x1=(-b+d)/(2*a);
x2=(-b-d)/(2*a);
x=-b/(2*a);
x1=(-b+d)/(2*a);
x2=(-b-d)/(2*a);
cout<
x
}
x1,x2
return 0;
}
Tamom
33-misol:Berilgan silindr o’q kesim silindr asoslarining diometrlari orqali o’tgan kesmani topuvchi algoritim tuzing.
Boshlash
Dasturi:
#include
#include
R,h
using namespace std;
int main(){
int S,r,h;
S=2*r*h;
cin>>r>>h;
S=2*r*h;
cout< return 0;
S
}
Tamom
34-misol:Uchburchakga ichki va tashqi chizilgan aylanalar radiuslarini hisoblash algoritmi.
Boshlash
Dastur:
#include
#include
A,b,c
using namespace std;
int main(){
int a,b,c,s,p,R,r;
p=(a+b+c)/2;
cin>>a>>b>>c;
p=(a+b+c)/2;
cout<
s=sqrt(p*(p-a)*(p-b)*(p-c));
s=sqrt(p*(p-a)*(p-b)*(p-c));
cout< R=(4*s)/(a*b*c);
R=(4*s)/(a*b*c);
cout<
r=(a+b+c)/(2*s);
cout<
R=(4*s)/(a*b*c);
r=(a+b+c)/(2*s)
return 0;
}
Tamom
R,r
Natija:
35-misol:Quyidagi ikkita berilgan masalalarni ishlash uchun ularga mos algoritm tuzing.
agar x≥0 shart rost bo‘lsa, tarmoq bo‘yicha y = x *x munosabatning qiymati, aks holda, y = 2*x munosabatning qiymati hisoblansin.
Boshlash
Dasturi:
#include
#include
x
using namespace std;
int main(){
int x,y;
cin>>x;
x>=0
if(x>=0){
y=x*x;
}
else{
y=2*x;
y=2*x;
y=x*x;
}
cout< return 0;
}
Tamom
36-misol: Quyidagi ifoda bilan berilgan munosabatni hisoblang
va shu misolning ishlash algoritmini tuzing.
Boshlash
Dastur:
#include
#include
b,a
using namespace std;
int main(){
int b,a,y,x;
x>0
cin>>b>>a>>x;
if(x>0){
y=b-x;
}
x<0
else if(x<0){
y=b-x;
y=a+x;
}
else{
y=a+b
y=a+x
y=a+b;
}
cout<
Tamom
return 0;
}
37-misol: Fibonachchi sonlarining n- hadini hisoblash algaritmini tuzing.
Dastur:
#include
using namespace std;
int main(){
int n,s=0;
cin>>n;
int a=0,a1=1,a2=0;
while(n!=a2){
s++;
a2=a1+a2;
a=a1;
a1=a2;
}
cout<return 0;
}
Boshlash
n
a=0,a1=1
a2=a1+a2
a2
a2
a=a1,
a1=a2.
Tamom
38-misol:To’g’ri uchburchakli chizilgan aylanani topish dasturini tuzing.
Boshlash
Dastur:
#include
#include
using namespace std;
a,b,c,r
int main(){
int a,b,c,r,s;
cin>>a>>b>>c>>r;
s=((a+b+c)*r)/2
s=((a+b+c)*r)/2;
cout< return 0;
}
s
Tamom
39-misol:Barcha yoqlari kvadratlardan iborat kubning diagonalini topish algoritmini tuzing.
Boshlash
Dastur:
#include
#include
a
using namespace std;
int main(){
float a,d;
cin>>a;
d=sqrt(3)*a
d=sqrt(3)*a;
cout< return 0;
}
d
Tamom
40-misol: Ikki xonali son berilgan. Uning birinchi raqamini(o`nliklar sonini ) aniqlang.
Boshlash
Dastur:
#include
N,A
using namespace std;
int main(){
A=N/10
int n,a;
Tamom
cin>>n;
a=n/10;
cout< return 0;
}
0> 0>
Do'stlaringiz bilan baham: |