Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://www.facebook.com/pages/C%C3%B9ng-h%E1%BB%8Dc-l%E1%BA%ADp-tr%C3%ACnh/632038696941833
- #include <iostream>
- #include <string>
- using namespace std;
- class SinhVien
- {
- protected:
- string MSSV, HoTen, DiaChi;
- int TongChi;
- float DTB;
- virtual void Input(istream &in) = 0;
- virtual void Output(ostream &out) const = 0;
- public:
- friend istream& operator >> (istream& in, SinhVien &SV)
- {
- fflush(stdin);
- cout << "Ten: ";
- getline(in, SV.HoTen);
- cout << "MSSV: ";
- getline(in, SV.MSSV);
- cout << "Dia Chi: ";
- getline(in, SV.DiaChi);
- cout << "Tong Chi: ";
- in >> SV.TongChi;
- cout << "DTB: ";
- in >> SV.DTB;
- SV.Input(in);
- return in;
- }
- friend ostream& operator << (ostream& out, const SinhVien &SV)
- {
- fflush(stdin);
- out << "Ten: " << SV.HoTen << endl;
- out << "MSSV: " << SV.MSSV << endl;
- out << "Dia Chi: " << SV.DiaChi << endl;
- out << "Tong Chi: " << SV.TongChi << endl;
- out << "DTB: " << SV.DTB << endl;
- SV.Output(out);
- return out;
- }
- virtual int XetTotNghiep() = 0;
- float GetDTB(){ return this->DTB; }
- int KieuSinhVien;
- };
- class SVDH : public SinhVien
- {
- private:
- string TenLuanVan;
- float DiemLV;
- public:
- void Input(istream &in)
- {
- fflush(stdin);
- cout << "Ten Luan Van: ";
- getline(in, this->TenLuanVan);
- cout << "Diem Luan Van: ";
- in >> this->DiemLV;
- }
- void Output(ostream &out) const
- {
- out << "Ten Luan Van: " << this->TenLuanVan << endl;
- out << "Diem Luan Van: " << this->DiemLV << endl;
- }
- int XetTotNghiep()
- {
- if (this->TongChi >= 170 && this->DiemLV >= 5.0 && this->DTB >= 5.0) return 1;
- return 0;
- }
- };
- class SVCD : public SinhVien
- {
- private:
- float DiemTN;
- public:
- void Input(istream &in)
- {
- cout << "Diem Tot Nghiep: ";
- in >> this->DiemTN;
- }
- void Output(ostream &out) const
- {
- out << "Diem Tot Nghiep: " << this->DiemTN << endl;
- }
- int XetTotNghiep()
- {
- if (this->TongChi >= 120 && this->DiemTN >= 5.0 && this->DTB >= 5.0) return 1;
- return 0;
- }
- };
- void main()
- {
- SinhVien **SV = NULL;
- int SoSinhVien, LuaChon;
- do
- {
- system("cls");
- cout << "So Sinh Vien Can Nhap: ";
- cin >> SoSinhVien;
- } while (SoSinhVien <= 0);
- SV = new SinhVien*[SoSinhVien];
- for (int i = 0; i < SoSinhVien; i++)
- {
- system("cls");
- cout << " Nhap SV thu: " << i + 1 << endl;
- do
- {
- cout << "1. Dai Hoc\n2. Cao Dang\n\tLua chon: ";
- cin >> LuaChon;
- } while (LuaChon <= 0 || LuaChon >= 3);
- switch (LuaChon)
- {
- case 1:
- SV[i] = new SVDH;
- break;
- case 2:
- SV[i] = new SVCD;
- break;
- }
- SV[i]->KieuSinhVien = LuaChon;
- cin >> *SV[i];
- }
- int SVTN = 0;
- for (int i = 0; i < SoSinhVien; i++)
- {
- if (SV[i]->XetTotNghiep() == 1) SVTN++;
- }
- cout << "So SV duoc tot nghiep: " << SVTN << endl;
- float max = -1;
- for (int i = 0; i < SoSinhVien; i++)
- {
- if (SV[i]->KieuSinhVien == 1)
- {
- if (max < SV[i]->GetDTB())
- {
- max = SV[i]->GetDTB();
- }
- }
- }
- if (max < 0) cout << "Ca truong deu thap diem, cu the DTB = 0\n";
- else cout << "SV Dai Hoc Co DTB Cao Nhat: " << max << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement