Samandar Abduvoitov 12-Labaratoriya ishi


Download 52.53 Kb.
Sana05.01.2022
Hajmi52.53 Kb.
#210931
Bog'liq
711guruh Samandar 12

711-19


Samandar Abduvoitov

12-Labaratoriya ishi


10 lik sanoq sistemasida berilgan ishorasiz haqiqiy sonni ko‘rsatilgan “p.m” formatda chop qiladigan FLOAT_PRINT sinf yaratilsin. Bu yerda p-son ko‘rinishidagi jami joylar (pozitsiya), m-sonning kasr qismidagi raqamlar soni. Natijani 2,8 va 16 lik sanoq sistemasidagi ko‘rinishini chop qiluvchi FLOAT_PRINT2, FLOAT_PRINT8, FLOAT_PRINT16 hosilaviy sinflar yaratilsin.

Dastur kodi:



#include

using namespace std;

class FLOAT_PRINT{

public:

int p,m;

void PRINT_NUM (){

cout<

}

};

class FLOAT_PRINT8: public FLOAT_PRINT {

public:

void dectooctal(int n)

{

int octalNum[100];

int i = 0;

while (n != 0) {

octalNum[i] = n % 8;

n = n / 8;

i++;

}

for (int j = i - 1; j >= 0; j--)

cout << octalNum[j];

}

};

class FLOAT_PRINT2: public FLOAT_PRINT{

public:

void dectobin(int n)

{

int octalNum[100];

int i = 0;

while (n != 0) {

octalNum[i] = n % 2;

n = n / 2;

i++;

}

for (int j = i - 1; j >= 0; j--)

cout << octalNum[j];

}

};
int main(){

FLOAT_PRINT f;

FLOAT_PRINT8 f8;

FLOAT_PRINT2 f2;

int m;
cout<<"sonning butun qismini kiriting:\n";

cin>>f.p;

m=f.p;

cout<<"sonning kasr qismini kiriting:\n";

cin>>f.m;

cout<<"siz kiritgan son:";

f.PRINT_NUM();

cout<<"\nSiz kiritgan son 8 lik sanoq sistemasida: \n";

f8.dectooctal(m);

cout<<"\nIkkilik sanoq sistemasida:\n";

f2.dectobin(m);

}
Natija:


Download 52.53 Kb.

Do'stlaringiz bilan baham:




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