Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include <iostream>
- //using namespace std;
- //
- //class PhanSo
- //{
- // int tuso, mauso;
- //public:
- // PhanSo(int tu = 0, int mau = 1)
- // {
- // tuso = tu;
- // mauso = mau;
- // }
- //
- // PhanSo operator + (PhanSo c) //*this b la PhanSo c
- // {
- // PhanSo p;
- // p.tuso = this->tuso * c.mauso + this->mauso * c.tuso;
- // p.mauso = this->mauso * c.mauso;
- // return p;
- // }
- // void Xuat()
- // {
- // cout << this->tuso << " / " << this->mauso;
- // }
- //};
- //
- //
- //
- //void main()
- //{
- // PhanSo a;
- // PhanSo b(1, 2);
- // PhanSo c(3);
- //
- // a = b + c;
- // a.Xuat();
- //}
- //NhanVien: ma nv, ho ten, tuoi, sdt, luong cb, mail, luong
- //LTV: so gio lam them
- //KCV: so loi phat hien duoc
- #include <iostream>
- #include <string>
- using namespace std;
- class NhanVien
- {
- protected:
- string MaNv, HoTen, SDT, Mail;
- int Tuoi, Luong, LuongCB;
- public:
- virtual void Nhap()
- {
- fflush(stdin);
- cout << "HoTen: ";
- getline(cin, HoTen);
- cout << "MaNv: ";
- getline(cin, MaNv);
- cout << "Mail: ";
- getline(cin, Mail);
- cout << "SDT: ";
- getline(cin, SDT);
- cout << "Tuoi: ";
- cin >> Tuoi;
- cout << "Luong co ban: ";
- cin >> LuongCB;
- }
- virtual void Xuat()
- {
- cout << "HoTen: " << HoTen << endl;
- cout << "MaNv: " << MaNv << endl;
- cout << "Mail: " << Mail << endl;
- cout << "SDT: " << SDT << endl;
- cout << "Tuoi: " << Tuoi << endl;
- cout << "Luong co ban: " << LuongCB << endl;
- }
- virtual void TinhLuong()
- {
- }
- int LayLuong()
- {
- return Luong;
- }
- };
- class LapTrinhVien : public NhanVien
- {
- int SoGioLamThem;
- public:
- void Nhap()
- {
- NhanVien::Nhap();
- cout << "So gio lam them: ";
- cin >> SoGioLamThem;
- }
- void Xuat()
- {
- NhanVien::Xuat();
- cout << "So gio lam them: " << SoGioLamThem << endl;
- cout << "Luong: " << Luong << endl;
- }
- void TinhLuong()
- {
- Luong = LuongCB + SoGioLamThem * 200000;
- }
- };
- class KiemChungVien : public NhanVien
- {
- int SoLoiPhatHien;
- public:
- void Nhap()
- {
- NhanVien::Nhap();
- cout << "So loi phat hien: ";
- cin >> SoLoiPhatHien;
- }
- void Xuat()
- {
- NhanVien::Xuat();
- cout << "So loi phat hien: " << SoLoiPhatHien << endl;
- cout << "Luong: " << Luong << endl;
- }
- void TinhLuong()
- {
- Luong = LuongCB + SoLoiPhatHien * 50000;
- }
- };
- class DSNV
- {
- NhanVien *NV[1024];
- int n;
- public:
- void Nhap()
- {
- cout << "So nhan vien trong cong ty (n < 1024): ";
- cin >> n;
- for (int i = 0; i < n; i++)
- {
- int c;
- cout << "1. Lap trinh vien\n2. Kiem chung vien\nLua Chon: ";
- cin >> c;
- if (c == 1)
- NV[i] = new LapTrinhVien();
- else if (c == 2)
- NV[i] = new KiemChungVien();
- NV[i]->Nhap();
- NV[i]->TinhLuong();
- }
- }
- void LietKe()
- {
- int LuongTB = 0;
- for (int i = 0; i < n; i++)
- {
- LuongTB += NV[i]->LayLuong();
- }
- LuongTB = LuongTB / n;
- for (int i = 0; i < n; i++)
- {
- if (NV[i]->LayLuong() <= LuongTB)
- NV[i]->Xuat();
- }
- }
- };
- void main()
- {
- DSNV ds;
- ds.Nhap();
- ds.LietKe();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement