Mình cần in danh sách cán bộ theo từng đơn vị nhưng chưa làm được.Rất mong các bạn chỉ giúp hướng giải quyết.???Thanks!
PHP Code:
#include <cstdlib>
#include <iostream>
#include <conio.h>
#include <iomanip>
#include <string>
using namespace std;
class CANBO
{
private:
char macb[10],madv[25],ht[20];
char ngaysinh[50];
protected:
double luong;
public:
void Nhap_cb()
{
cout<<"\nMa can bo:";cin.ignore(1);cin.get(macb,20);
cout<<"\nMa don vi:";cin.ignore(1);cin.get(madv,20);
cout<<"\nHo ten:";cin.ignore(1);cin.get(ht,20);
cout<<"\nNgay sinh:";cin.ignore(1);cin.get(ngaysinh,50);
}
void Hienthi_cb()
{
cout<<"\n"<<setw(9)<<macb<<setw(9)<<madv<<setw(13)<<ht<<setw(15)<<ngaysinh<<setw(13)<<luong<<endl;
}
};
class LUONG:virtual public CANBO
{
float pc,hsl,bh;
//float luong[100];
public:
LUONG()
{
pc=0.0;
hsl=0.0;
bh=0.0;
}
LUONG(float a,float b,float c)
{
pc=a;
hsl=b;
bh=c;
}
void nhap_luong()
{
cout<<"\nTien Phu cap: ";
cin>>pc;
cout<<"\n He so luong: ";
cin>>hsl;
cout<<"\nTien Bao hiem: ";
cin>>bh;
luong=hsl*290000+pc-bh;
}
void hienthi_luong()
{
cout<<"\nTien Phu cap: "<<pc;
cout<<"\n He so luong: "<<hsl;
cout<<"\nTien Bao hiem: "<<bh;
}
};
class info:public LUONG
{};
int main(int argc, char *argv[])
{
info cb[100];
int n,i;
cout<<"\nTHONG TIN CAN BO";
cout<<"\nSo can bo:";cin>>n;
for (i=0;i<n;i++)
{cout<<"\nCan bo thu "<<i+1;
cb[i].Nhap_cb();
cb[i].nhap_luong();
}
cout<<"\nDANH SACH CAN BO";
cout<<"\n| Ma can bo |Ma dv| Ho ten | Ngay sinh | Luong thang |";
for (i=0;i<n;i++)
{cb[i].Hienthi_cb();
}
system("PAUSE");
return EXIT_SUCCESS;
}