0% found this document useful (0 votes)
7 views2 pages

Bai 1

c++ code

Uploaded by

21521292
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Bai 1

c++ code

Uploaded by

21521292
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <iostream>

#include <vector>
using namespace std;

struct Hoso
{
private:
string HoTen;
float Diem;
string Loai;
public:
void Nhap();
void Xuat();
};

struct DanhSachHS
{
private:
vector<Hoso> danhSach;
public:
void NhapDanhSach();
void XuatDanhSach();
};

int main()
{
DanhSachHS ds;
ds.NhapDanhSach();
ds.XuatDanhSach();
return 0;
}

void Hoso::Nhap()
{
cout << "Nhap Ho ten: "; getline(cin, HoTen);
cout << "Nhap Diem: "; cin >> Diem;
if(Diem>=9)
{
Loai = "Gioi";
}
else if(Diem>=7)
{
Loai = "Kha";
}
else if(Diem>=5)
{
Loai = "TB";
}
else
{
Loai = "Khong Dat";
}
cin.ignore();
}

void Hoso::Xuat()
{
cout << "\n=> THONG TIN HOC SINH: \n";
cout << "Ho ten: " << HoTen << endl
<< "Diem: " << Diem << endl
<< "Xep loai: " << Loai << endl;
}

void DanhSachHS::NhapDanhSach()
{
int n;
cout << "Nhap so luong hoc sinh: ";
cin >> n;
cin.ignore();

for (int i = 0; i < n; ++i)


{
cout << "\nNhap thong tin hoc sinh thu " << i + 1 << ":\n";
Hoso hs;
hs.Nhap();
danhSach.push_back(hs);
}
}

void DanhSachHS::XuatDanhSach()
{
cout << "\n----------DANH SACH HOC SINH----------\n";
for (int i = 0; i < danhSach.size(); ++i)
{
cout << "\n-----HOC SINH THU " << i + 1 << "-----";
danhSach[i].Xuat();
}
}

You might also like