A Uchta sondan kattasini topuvchi funksiya hosil qiling. Ushbu funksiya yordamida a,b,c va a1,b1,c1 lardan kattasini toping



Download 0,58 Mb.
Sana14.01.2023
Hajmi0,58 Mb.
#899487
Bog'liq
javoblar


a) Uchta sondan kattasini topuvchi funksiya hosil qiling. Ushbu funksiya yordamida a,b,c va a1,b1,c1 lardan kattasini toping.
#include
using namespace std;
int findLargest(int, int, int);
int main()
{
int a, b, c, larg;
cout<<"Uchta sonni kiriting: ";
cin>>a>>b>>c;
larg = findLargest(a, b, c);
cout<<"\nKatta son = "<cout<return 0;
}
int findLargest(int a1, int b1, int c1)
{
if(a1>b1)
{
if(b1>c1)
return a1;
else
{
if(c1>a1)
return c1;
else
return a1;
}
}
else
{
if(b1>c1)
return b1;
else
return c1;
}
}

Printer va skaner class larini yarating va ularni bog‘lovchi funksiyalar yarating
#include
#include
#include
#include
#include
using namespace std;
namespace mySpace
{
class Printer{
string nomi, turi;
int yili, soni;
public:
friend void qidirish(mySpace::Printer k[], int n);
friend void saralash(mySpace::Printer k[], int n);
friend void ozgartirish(mySpace::Printer k[], int n);
void set_malumot(string N, string T, int Y){
nomi=N;
turi=T;
yili=Y;
srand(time(NULL));
soni=rand()%20+5;
}

void get_malumot(){


cout << setw(15) << nomi << setw(15) << turi << setw(15) << yili << setw(15) << soni << endl;;
}
void cha(){
cout << setw(5) << "N" << setw(15) << "Nomi" << setw(15) << "Turi" << setw(15) << "Yili" << setw(15) << "Soni" << endl;
}

void qidirish(mySpace::Printer k[], int n){


cout << "Qidirayotgan printer nomini kiriting : ";
string s; cin >> s; bool bor=false;
cha();
for(int i=0; iif(k[i].nomi.compare(s)==0){
int b=i;
bor=true;
cout << setw(5) << ++b;
k[i].get_malumot();
}
}
if(!bor){
cout << "Bunday nomdagi printer topilmadi.\n";
}
}
void saralash(mySpace::Printer k[], int n){
cout << "Nomi bo`yicha saralash holati.\n\n";
mySpace::Printer templ;
for(int i=0; ifor(int j=0; jif(k[i].nomi.compare(k[j].nomi)<0){
templ=k[i];
k[i]=k[j];
k[j]=templ;
}
}
}
cha();
int b=1;
for(int i=0; icout << setw(5) << b;
k[i].get_malumot();
b++;
}
}
void ozgartirish(mySpace::Printer k[], int n){
int a;
cout << "Qaysi Printer malumotlarini o`zgartirishni hohlaysiz : ";
string s; cin >> s; bool bor=false;
for(int i=0; iif(k[i].nomi.compare(s)==0){
bor=true;
cout << "1 : Harid qilish\n" << "2 : Sotish\n";
cin >> a;
switch(a){
case 1 :
{
int b=i;
k[i].soni++;
cha();
cout << setw(5) << ++b;
k[i].get_malumot();
cout << endl;
break;
}
case 2 : {
if(k[i].soni==0){
cout << "Bunday Printer qolmagan.\n";
} else{
int b=i;
k[i].soni--;
cha();
cout << setw(5) << ++b;
k[i].get_malumot();
cout << endl;
}
break;
}
default : cout << "Bunday amalni bajarib bo`lmaydi.\n";
}
}
}
if(!bor){
cout << "Bunday nomdagi Printer topilmadi.\n";
}
}
};

class skaner{


string nomi, turi;
int yili, soni;
public:
friend void qidirish(mySpace::skaner q[], int n);
friend void saralash(mySpace::skaner q[], int n);
friend void ozgartirish(mySpace::skaner q[], int n);
void set_malumot(string N, string T, int Y){
nomi=N;
turi=T;
yili=Y;
srand(time(0));
soni=rand()%20+5;
}
void get_malumot(){
cout << setw(15) << nomi << setw(15) << turi << setw(15) << yili << setw(15) << soni << endl;
}
void cha(){
cout << setw(5) << "N" << setw(15) << "Nomi" << setw(15) << "Turi" << setw(15) << "Yili" << setw(15) << "Soni" << endl;
}
void qidirish(mySpace::skaner q[], int n){
cout << "Qidirayotgan skaner nomini kiriting : \n";
string s; cin >> s; bool bor=false;
for(int i=0; iif(q[i].nomi.compare(s)==0){
bor=true;
int b=i;
cha();
cout << setw(5) << ++b;
q[i].get_malumot();
}
}
if(!bor){
cout << "Bunday nomdagi skaner topilmadi.\n";
}
}
void saralash(mySpace::skaner q[], int n){
cout << "Nomi bo`yicha saralash holati.\n\n";
mySpace::skaner templ;
for(int i=0; ifor(int j=0; jif(q[i].nomi.compare(q[j].nomi)<0){
templ=q[i];
q[i]=q[j];
q[j]=templ;
}
}
}
cha();\
int b=1;
for(int i=0; icout << setw(5) << b;
q[i].get_malumot();
b++;
}
}
void ozgartirish(mySpace::skaner q[], int n){
int a;
cout << "Qaysi skaner malumotlarini o`zgartirishni hohlaysiz.\n";
string s; cin >> s; bool bor=false;
for(int i=0; iif(q[i].nomi.compare(s)==0){
bor=true;
cout << "1 : Harid qilish\n" << "2 : Sotish\n";
cin >> a;
switch(a){
case 1 : {
cha();
int b=i;
cout << setw(5) << ++b;
q[i].get_malumot();
break;
}
case 2 : {
if(q[i].soni==0){
cout << "Bu skaner boshqa qolmagan.\n";
} else {
int b=i;
cha();
cout << setw(5) << ++b;
q[i].get_malumot();
}
break;
}
default : cout << "Bunday amalni bajarib bo`lmaydi.\n";
}
}
}
if(!bor){
cout << "Bunday nomdagi skaner topilmadi.\n";
}
}
};
}
using namespace mySpace;
int main(){
string nomi[]={"cassl", "franch", "china", "coss"};
string turi[]={"aser", "conoi", "Epson", "HP printer"};
int yili[]={2005, 2003, 20010, 2018};
cout << setw(45) << "<>\n\n";
skaner k[100];
skaner ka;
ka.cha();
int t=1;

for(int i=0; i<4; i++){


k[i].set_malumot(nomi[i], turi[i], yili[i]);
cout << setw(5) << t;
k[i].get_malumot();
t++;
}
cout << endl;
ka.qidirish(k,4);
ka.saralash(k,4);
ka.ozgartirish(k,4);
cout << setw(45) << "<
>\n\n";
Printer q[100];
Printer qa;
qa.cha();
int b=1;

for(int i=0; i<4; i++){


q[i].set_malumot(nomi[i], turi[i], yili[i]);
cout << setw(5) << b;
q[i].get_malumot();
b++;
}
cout << endl;

qa.qidirish(q,4);


qa.saralash(q,4);
qa.ozgartirish(q,4);
}

Uchburchak sinfini yarating. Unda kamida 5 ta maydon va ularni ekranga chiqaruvchi, qayta ishlovchi usullarni yarating.


#include
#include
using namespace std;
class Uchburchak {
int a,b,c;
public:
Uchburchak() {
cout << "Uchburchakning tomonlari: " << endl;
}
Uchburchak(int k,float l) {
cout << "Perimetri: " << k << endl;
cout << "Yuzasi: " << l << endl;
}
};
int main() {
int a, b, c,p;
float s;
Uchburchak ();
cout << "a="; cin >> a;
cout << "b="; cin >> b;
cout << "c="; cin >> c;
p = a + b + c;
s = sqrt((p / 2)*(p / 2 - a)*(p / 2 - b)*(p / 2 - c));
Uchburchak(p,s);
return 0;
}

Firmaning xodimlari to‘g‘risida quyidagi ma’lumotlar ma’lum: Familiyasi, ismi, jinsi, farzandi (bor yoki yo‘q) haqida ma’lumot berilgan. Farzandi bo‘lgan ayol xodimlar ro‘yxatini chop etuvchi dastur tuzing.


#include
using namespace std;

class Firma {


public:
void myFunction() {
cout << "::::::Xodim:::::::"<cout << "Mo`minov Sharifjon"<cout << "Turmush Qurgan"<cout << "Farazndi 2ta"<cout << "Oilaviy ahvoli YAXSHI"<};
class Xodim: public Firma {
};
class Xodim2: public Xodim {
};
int main() {
Xodim2 myObj;
myObj.myFunction();
return 0;
}

17.Berilgan ikkita satrdagi bir xil belgilar sonini aniqlaydigan dastur tuzing.


#include
#include

using namespace std;



int main()
{
int x = 0;
string s1, s2;
getline(cin, s1);
getline(cin, s2);
for (int i = 0; i < max(s1.length(), s2.length()); i++)
for (int j = 0; j < min(s1.length(), s2.length()); j++)
{
if (s1[i] == s2[j] && s2.length() < s1.length())
x++;
if (s2[i] == s1[j] && s2.length() > s1.length())
x++;
}
cout << x;
}

Download 0,58 Mb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish