180. Uchta turli xil sonlarning maksimal va minimal qiymatlarini aniqlang.
#include
//180-masala @TBCLbot
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
cout<<"max="<cout<<"min="<return 0;
}
181. Berilgan satrdagi dastlabki 4 ta so’zdan yangi satr hosil qiling.
182. Berilgan ikkita satrlarni birlashtirish dasturini tuzing.
#include
//182-masala @TBCLbot
using namespace std;
int main()
{
string s,s1,s2;
cout<<"Satr kiriting:s1=";getline(cin,s1);
cout<<"Satr kiriting:s2=";getline(cin,s2);
s=s1+s2;
cout<<"s1,s2satrlar birlashmasi: "<return 0;
}
183. Uch xonali son berilgan. Jumlani rostlikka tekshiring: „Ushbu sonning barcha raqamlari har xil”.
#include
//183-misol;@TBCLbot
using namespace std;
int main()
{
int n1,n2,n3;
n1=n/100;
n2=(n/10)%10;
n3=n%10;
if(n1!=n2&&n2!=n3&&n1!=n3)
cout<<"Rost";
else cout<<”Yolg’on”;
}
return 0;
}
184. Aylananing uzunligi C ma’lum. Ushbu aylanaga ichki chizilgan kvadratning perimetrini topish dasturini tuzing.
#include
//184-masala @TBCLbot
using namespace std;
int main()
{
float C,a=0;
cout<<"C=";cin>>C;
a=2*sqrt(2)*C*1./M_PI;
cout<<"Kvadrat Perimetri:"<<4*a;
return 0;
}
185. Berilgan son uchun uning hamma bo’luvchilarini toping va natijani faylga yozing.
#include
//185-masala @TBCLbot
using namespace std;
int main()
{
//Ma'lumot qo'shish uchun ochish
ofstream file("d:\\Buluvchilar.txt",ios_base::app);
//Fayl mavjud yoki mavjud emasligini aniqlash
if(file.is_open())
{
int a,i=1;
cout<<" Fayl yaratildi!\n";
cout<<" a=";cin>>a;
//a soning bo'luvchilarini topish
file<<" a="<while(a!=i)
{
if(a%i==0)
{
cout<<" "<file<}
i++;
}
//Faylga yozish
file<}
//Fayil mavjud emasligini chop etish
else
{
cout << "Fayl topilmadi";
cin.get();
return -1;
}
return 0;
}
186. N ta son berilgan bu sonlarning yig’indisini faylga yozing.
#include
//186-masala @TBCLbot
using namespace std;
int main()
{
//Ma'lumot qo'shish uchun ochish
ofstream file("d:\\Buluvchilar.txt",ios_base::app);
//Fayl mavjud yoki mavjud emasligini aniqlash
if(file.is_open())
{
int n,i=1,S=0,m;
cout<<" Fayl yaratildi!\n";
cout<<" n=";cin>>n;
//n ta soning yig’indisini topish
for(int i=1;i<=n;i++)
{
cin>>m;
S+=m;
}
file<}
//Faylga yozish
file<}
//Fayil mavjud emasligini chop etish
else
{
cout << "Fayl topilmadi";
cin.get();
return -1;
}
return 0;
}
187. N ta son berilgan bu sonlardan eng kattasini faylga yozing.
#include
//187-masala @TBCLbot
using namespace std;
int main()
{
//Ma'lumot qo'shish uchun ochish
ofstream file("d:\\Buluvchilar.txt",ios_base::app);
//Fayl mavjud yoki mavjud emasligini aniqlash
if(file.is_open())
{
int n,i=1,S,m;
cout<<" Fayl yaratildi!\n";
cout<<" n=";cin>>n;
cin>>m;
S=m;
for(int i=1;i<=n;i++)
{
cin>>m;
if(S>m)S=m;
}
file<}
//Faylga yozish
file<}
//Fayil mavjud emasligini chop etish
else
{
cout << "Fayl topilmadi";
cin.get();
return -1;
}
return 0;
}
188. N ta son faylga yozilgan. Bu fayldan ma’lumotlarni o’qib, barcha sonlarning yig’indisini chop eting.
#include
//188-masala @TBCLbot
using namespace std;
int main()
{
ifstream files;
files.open("d:\Bugun.txt");
//fileni ochish
int a,S=0;
if(files.is_open())
{
//file ochilganligini aniqlash
cout<<" Fayl yaratildi!\n";
while(!files.eof())
{
//fileni oxirigacha o'qish
files >> a ;
S+=a;
//filega yozish
}
cout<<"S="<}
else
{
cout<<" Fayl topilmadi!";
cin.get();
return -1;
}
return 0;
}
189. N natural son berilgan. Berilgan natural sonning raqamlarini yig’indisini aniqlash funksiyasini yozing va unga murojaat qiling.
#include
//189-masala @TBCLbot
using namespace std;
int SUMMA(int n)
{
int s=0,k;
while(n)
{
k=n%10;
s+=k;
n/=10;
}
return s;
}
int main()
{
int n;
cin>>n;
cout<return 0;
}
190. N natural son berilgan. Berilgan natural sonning toq yoki juftligini aniqlash funksiyasini tuzing va unga murojaat qiling.
#include
//190-masala @TBCLbot
using namespace std;
bool Son(int n)
{
if(n%2==0)
return 1;
else return 0;
}
int main()
{
int n;
cin>>n;
if(Son(n))
cout<<"Berilgan son juft son";
else
cout<<"Berilgan son toq son";
return 0;
}
191. N natural son berilgan. Berilgan natural sonning 3 ga karrali ekanligini aniqlash funksiyasini tuzing va unga murojaat qiling.
#include
//191-masala @TBCLbot
using namespace std;
bool Son(int n)
{
if(n%3==0)
return 1;
else return 0;
}
int main()
{
int n;
cin>>n;
if(Son(n))
cout<<"Berilgan 3 ga karrali";
else
cout<<"Berilgan 3 ga karrali emas";
return 0;
}
192. N natural son berilgan. Uning oxirgi raqamini aniqlash funksiyasini tuzing va unga murojaat qiling.
#include
//192-masala @TBCLbot
using namespace std;
int Son(int n)
{
return n%10;
}
int main()
{
int n;
cin>>n;
cout<<"Berilgan sonoing oxirgi raqami: "<return 0;
}
193. M va N butun sonlari berilgan. ifodani hisoblash funksiyasini yozing va unga murojaat qiling.
#include
//193-masala @TBCLbot
using namespace std;
float Son(int n,int m)
{
float k;
k=(m+n)*1./(2*m*n);
return k;
}
int main()
{
int n,m;
cout<<"M=";cin>>n;
cout<<"N=";cin>>m;
cout<<"Ifodaning qiymati: "<return 0;
}
194. M va N butun sonlari berilgan. ifodani hisoblash funksiyasini yozing va unga murojaat qiling.
#include
//194-masala @TBCLbot
using namespace std;
float Son(int n,int m)
{
float k;
k=(m*m+2*n)*1./(m*n);
return k;
}
int main()
{
int n,m;
cout<<"M=";cin>>n;
cout<<"N=";cin>>m;
cout<<"Ifodaning qiymati: "<return 0;
}
195. N natural son berilgan. Berilgan natural sonning K ga karrali ekanligini aniqlash funksiyasini tuzing va unga murojaat qiling.
#include
//195-masala @TBCLbot
using namespace std;
bool Son(int n,int k)
{
if(n%k==0)
return 1;
else return 0;
}
int main()
{
int n,k;
cout<<"n=";cin>>n;
cout<<"k=";cin>>k;
if(Son(n,k))
cout<<"Karrali";
else cout<<"Karrali emas";
return 0;
}
196. 10 dan 1000 gacha bo’lgan barcha butun sonlarning kublarini chop etuvchi dastur tuzing.
#include
//196-masala @TBCLbot
using namespace std;
int main()
{
for(int i=10;i<=1000;i++)
cout<return 0;
}
197. S1 va S2 lar berilgan. Bu ikki satrning uzunliklarini qo’shish dasturing tuzing.
#include
//197-masala @TBCLbot
using namespace std;
int main()
{
string s1,s2;
int k;
cout<<"Satr kiriting:s1=";getline(cin,s1);
cout<<"Satr kiriting:s2=";getline(cin,s2);
k=s1.size()+s2.size();
cout<<"s1,s2satrlar uzunliklari yig’indisi: "<return 0;
}
198. a1,a2,… ,an haqiqiy sonlar berilgan. Eng katta va eng kichik elementlarini toping va quyidagi ifodani hisoblang . Bu yerda eng katta son, eng kichik son .
#include
//198-masala @TBCLbot
using namespace std;
int main()
{
int m,max1,min1,n;
cout<<"n=";cin>>n;
cin>>m;
max1=m;
min1=m;
for(int i=1;i{
cin>>m;
if(m>max1)max1=m;
if(m}
cout<<2*max1+3*min1;
return 0;
}
199. Uchburchakning tomonlari berilgan: a,b,c. Bu tomonlarga uchburchakning balandligini aniqlash funksiyasini yozing va unga murojaat qiling.
#include
//118-masala @TBCLbot
using namespace std;
float balandlik(float&a1,float&b,float&c)
{
float s,p;
p=(a1+b+c)*1./2;
s=sqrt(p*(p-a1)*(p-b)*(p-c));
a1=2*s*1./a1;
b=2*s*1./b;
c=2*s*1./c;
return 0;
}
int main()
{
float a1,b,c;
cout<<"uchburchak tomonlari:";cin>>a1>>b>>c;
balandlik(a1,b,c);
cout<<"ha="<return 0;
}
200. Uchburchakning tomonlari berilgan: a,b,c. Bu tomonlarga uchburchakning medianasini aniqlash funksiyasini yozing va unga murojaat qiling
#include
//200-masala @TBCLbot
using namespace std;
float mediana(float&a,float&b,float&c)
{
float a1,b1,c1;
a1=a;
b1=b;
c1=c;
a=sqrt(2*(b1*b1+c1*c1)-a1*a1)*1./2;
b=sqrt(2*(a1*a1+c1*c1)-b1*b1)*1./2;
c=sqrt(2*(a1*a1+b1*b1)-c1*c1)*1./2;
return 0;
}
int main()
{
float a,b,c;
cout<<"uchburchak tomonlari:";cin>>a>>b>>c;
mediana(a,b,c);
cout<<"ma="<return 0;
}
Do'stlaringiz bilan baham: |