Mavzu: Class va friend funksiyalari uchun misollar


Download 285.59 Kb.
Sana02.01.2022
Hajmi285.59 Kb.
#190177
Bog'liq
lab10 topshiriq


MUHAMMAD AL-XORAZMIY NOMIDAGI

TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI



Dasturlash 1 fanidan laboratoriya mashg`ulot 10

Mavzu: Class va friend funksiyalari uchun misollar.

711-20 guruh talabasi Yo`ldashev Zufarbek

Variant 10.

Masalaning berilishi:

1.

Natija:


#include

#include

#include

#include

using namespace std;

int main()

{

char q[80]="10110";



float n,a;int i,w,s=0;

n = strlen(q);

for(i=n-1;i>=0;i--)

{a=pow(2,i);

w=pow(10,i);

s=s+q/w*a;

cout<

cout<

return 0;

}



2-masala:

Natija:


#include

#include

#include

#include

using namespace std;

int main()

{

char a[80],b[80];



string s;

cout<<"a satrni kiriting: "; cin>>a;

cout<<"b satrni kiriting: "; cin>>b;

s=strcpy(b+3,a+3);

cout<

return 0;}





3-masala:

Natija:


#include

#include

#include

using namespace std;

class litsey

{

public:



char nomi[100];

int yili,uquvchi_soni;

public:

void kir(int n, litsey a[])

{

for(int i=0;i

{

cout<<"Litsey nomi: "; cin>>a[i].nomi;

cout<<"Litsey yili: "; cin>>a[i].yili;

cout<<"Litsey o`quvchilar soni: "; cin>>a[i].uquvchi_soni;

}

}

void sarala(int n, litsey a[])



{

int i,j;

for(j=0;j<=1000000;j++)

for(i=0;i

if(a[i].yili==j)

cout<

}

void sarala1(int n, litsey a[])



{

int i,j;

for(j=0;j<=1000000;j++)

for(i=0;i

if(a[i].uquvchi_soni==j)

cout<

}

};

int main()



{

int n,i; litsey a[50];

cout<<"Nechta litsey: "; cin>>n;

a[i].kir(n,a);

a[i].sarala(n,a);

a[i].sarala1(n,a);



return 0;

}


Download 285.59 Kb.

Do'stlaringiz bilan baham:




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