?? canbo.cpp
字號:
#include<conio.h>
#include<stdio.h>
#include<iostream.h>
#include<iomanip.h>
class CANBO
{private:
char hoten[20];
int mcb,ngsinh,mdv;
public:
int gan();
void nhap();
void hienthi();
};
void CANBO::nhap()
{cout<<"\n nhap ho ten:";gets(hoten);
cout<<"\n nhap ma can bo:";cin>>mcb;
cout<<"\n nhap ngay sinh :";cin>>ngsinh;
cout<<"\n nhap ma don vi:";cin>>mdv;}
void CANBO::hienthi()
{cout<<mdv<<setw(10)<<mcb<<setw(10)<<ngsinh<<setw(12)<<hoten;}
int CANBO::gan()
{return mdv;}
class LUONG:public CANBO
{private:
int pc,hsl,bh;
public :
int tinh_luong()
{return (hsl*290000+pc-bh);}
void nhap_luong()
{nhap();
cout<<"\n nhap phu cap:" ;cin>>pc;
cout<<"\n nhap he so luong:";cin>>hsl;
cout<<"\n nhap tien bao hiem :";cin>>bh;}};
void main()
{int n,i,j;
LUONG *cb;
cout<<"nhap so can bo:";cin>>n;
cb=new LUONG [n];
for(i=0;i<n;i++)
{cout<<"nhap du lieu cua can bo thu"<<i+1<<":\n";
cb[i].nhap_luong();}
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if(cb[i].gan()>cb[j].gan())
{LUONG tam=cb[i];
cb[i]=cb[j];
cb[j]=tam;}
cout<<setw(20)<<"DANH SACH TIEN LUONG\n";
cout<<"madonvi"<<setw(10)<<"macanbo"<<setw(10)<<"ngaysinh"<<setw(7)<<"hoten"
<<setw(14)<<"tienluong"<<"\n";
for(i=0;i<n;i++)
{cout<<"\n";cb[i].hienthi();
cout<<setw(10)<<cb[i].tinh_luong();}
getch();}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -