#include <iostream>
#include <string>
using namespace std;
struct HocSinh{
string sHoten;
float fDiemtoan;
float fDiemvan;
float fDiemTB;
};

void NhapDuLieuHocSinh(HocSinh h[],int n)
{
for(int i=1;i<=n;i++)
{
cin.ignore();
cout<<"Nhap ho ten hoc sinh: ";
cin>>h[i].sHoten;
getline(cin,h[i].sHoten);
cout<<"Nhap diem toan: ";
cin>>h[i].fDiemtoan;
cout<<"Nhap diem van: ";
cin>>h[i].fDiemvan;
float dtb=(h[i].fDiemtoan+h[i].fDiemvan)/2;
h[i].fDiemTB=dtb;
}
}
void XuatTrungBinh(HocSinh h[],int n)
{
int tg;
for(int i=0;i<n-1;i++)
{
for(int j=i+1;j<n;j++)
{
if(h[i].fDiemTB> h[j].fDiemTB)
{
tg = h[i].fDiemTB;
h[i].fDiemTB=h[j].fDiemTB;
h[j].fDiemTB=tg;
}
}
}
cout<<h[n].sHoten;
cout<<h[n].fDiemtoan<<"\t"<<h[n].fDiemvan<<"\t"<<h[n].fDiemTB;
}
int main()
{
int n;
cout<<"Nhap so hoc sinh: ";
cin>>n;
HocSinh h[100];
NhapDuLieuHocSinh(h,n);
XuatTrungBinh(h,n);
return 0;
}