Untitled
unknown
c_cpp
a year ago
1.4 kB
4
Indexable
Never
#include <iostream> #include <iomanip> #include <string> using namespace std; struct HOCSINH{ string ten; float trungBinh; }; struct LOPHOC{ string ten; int siSo; HOCSINH* ds; }; int main(){ string buffer = ""; getline(cin, buffer); int n = stoi(buffer); LOPHOC* lop = new LOPHOC[n]; for (int i = 0; i < n; i++){ getline(cin, buffer); lop[i].ten = buffer; getline(cin, buffer); lop[i].siSo = stoi(buffer); lop[i].ds = new HOCSINH[lop[i].siSo]; for (int j = 0; j < lop[i].siSo; j++){ getline(cin, lop[i].ds[j].ten); getline(cin, buffer); lop[i].ds[j].trungBinh = stof(buffer); } } for (int i = 0; i < n; i++){ cout << lop[i].ten << '\n'; for (int j = 0; j < lop[i].siSo; j++){ cout << lop[i].ds[j].ten << '\n'; } } cout << '\n'; int dongNhat = 0; for (int i = 0; i < n; i++){ if (lop[i].siSo > lop[dongNhat].siSo){ dongNhat = i; } } cout << lop[dongNhat].ten << '\n'; string ten = ""; float tb = 0; for (int i = 0; i < n; i++){ for (int j = 0; j < lop[i].siSo; j++){ if (tb < lop[i].ds[j].trungBinh){ tb = lop[i].ds[j].trungBinh; ten = lop[i].ds[j].ten; } } } cout << ten; return 0; }