#include <bits/stdc++.h>
using namespace std;
class SV{
private :
char msv[ 15 ] ,nganh[ 20 ] ;
string ten;
string xep;
int ng,th,nam;
float toan,van,tin,tong;
public :
void nhap( ) {
cout << "Nhap ho ten: " ; getline( cin ,ten) ;
cout << "Ma sinh vien: " ; cin .getline ( msv,15 ) ;
cout << "Nganh hoc: " ; cin .getline ( nganh,20 ) ;
cout << "Ngay sinh(date): " ; cin >> ng >> th >> nam;
while ( ng > 31 ) {
cout << "Moi nhap lai ngay: " ; cin >> ng;
}
while ( th > 12 ) {
cout << "Moi nhap lai thang: " ; cin >> th;
}
while ( nam > 2024 ) {
cout << "Moi nhap lai nam: " ; cin >> nam;
}
cout << "Nhap diem toan: " ; cin >> toan;
cout << "Nhap diem van: " ; cin >> van;
cout << "Nhap diem tin: " ; cin >> tin;
cin .ignore ( ) ;
cout << endl;
}
void tinh( ) {
tong = ( toan* 4 + van* 4 + tin* 2 ) / 10 ;
if ( tong >= 9 ) {
xep = "Xuat sac" ;
} else
if ( tong >= 7.5 ) {
xep = "Gioi" ;
} else
if ( tong >= 6 ) {
xep = "Kha" ;
} else
if ( tong >= 4 ) {
xep = "Trung binh" ;
} else
if ( tong < 4 ) {
xep = "Yeu" ;
}
}
void xuat( ) {
cout << setw( 20 ) << left<< ten
<< setw( 15 ) << left<< msv;
if ( ng< 10 ) cout << "0" << ng<< "/" ;
else cout << ng<< "/" ;
if ( th < 10 ) cout << "0" << th<< "/" ;
else cout << nam<< "/" ;
cout << setw( 10 ) << left<< nam
<< setw( 10 ) << left<< nganh
<< setw( 13 ) << left<< tong
<< setw( 10 ) << left<< xep<< endl;
}
float gettong( ) {
return this- > tong;
}
int getten( ) {
return this- > ten.size ( ) ;
}
} ;
bool cmp( SV a, SV b) {
if ( a.gettong ( ) < b.gettong ( ) ) return a.gettong ( ) ;
// if(a.gettong() > b.gettong()) return b.gettong();
// else{
if ( a.gettong ( ) == b.gettong ( ) ) {
if ( a.getten ( ) < b.getten ( ) ) return a.getten ( ) ;
}
// else return b.getten();
// }
// }
}
int main( ) {
int n;
cout << "Nhap so luong sv: " ; cin >> n;
SV sv[ n] ;
cin .ignore ( ) ;
for ( int i = 0 ; i < n; i++ ) {
sv[ i] .nhap ( ) ;
sv[ i] .tinh ( ) ;
}
sort( sv,sv+ n,cmp) ;
cout << endl<< "--------\n " ;
cout << setw( 20 ) << left<< "Ho va ten"
<< setw( 15 ) << left<< "Ma sinh vien"
<< setw( 16 ) << left<< "Ngay sinh"
<< setw( 10 ) << left<< "Nganh"
<< setw( 13 ) << left<< "Diem tong"
<< setw( 10 ) << left<< "Xep loai" << endl;
for ( int i = 0 ; i < n; i++ ) {
sv[ i] .xuat ( ) ;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNsYXNzIFNWewogICAgcHJpdmF0ZToKICAgICAgICBjaGFyIG1zdlsxNV0sbmdhbmhbMjBdOwogICAgICAgIHN0cmluZyB0ZW47CiAgICAgICAgc3RyaW5nIHhlcDsKICAgICAgICBpbnQgbmcsdGgsbmFtOwogICAgICAgIGZsb2F0IHRvYW4sdmFuLHRpbix0b25nOwogICAgcHVibGljOgogICAgICAgIHZvaWQgbmhhcCgpewogICAgICAgICAgICBjb3V0PDwiTmhhcCBobyB0ZW46ICI7IGdldGxpbmUoY2luLHRlbik7CiAgICAgICAgICAgIGNvdXQ8PCJNYSBzaW5oIHZpZW46ICI7IGNpbi5nZXRsaW5lKG1zdiwxNSk7CiAgICAgICAgICAgIGNvdXQ8PCJOZ2FuaCBob2M6ICI7IGNpbi5nZXRsaW5lKG5nYW5oLDIwKTsKICAgICAgICAgICAgY291dDw8Ik5nYXkgc2luaChkYXRlKTogIjsgY2luID4+IG5nID4+IHRoID4+IG5hbTsKICAgICAgICAgICAgd2hpbGUobmcgPiAzMSl7CiAgICAgICAgICAgICAgICBjb3V0PDwiTW9pIG5oYXAgbGFpIG5nYXk6ICI7IGNpbj4+bmc7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgd2hpbGUodGggPiAxMil7CiAgICAgICAgICAgICAgICBjb3V0PDwiTW9pIG5oYXAgbGFpIHRoYW5nOiAiOyBjaW4+PnRoOwogICAgICAgICAgICB9CiAgICAgICAgICAgIHdoaWxlKG5hbSA+IDIwMjQpewogICAgICAgICAgICAgICAgY291dDw8Ik1vaSBuaGFwIGxhaSBuYW06ICI7IGNpbj4+bmFtOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGNvdXQ8PCJOaGFwIGRpZW0gdG9hbjogIjsgY2luID4+IHRvYW47CiAgICAgICAgICAgIGNvdXQ8PCJOaGFwIGRpZW0gdmFuOiAiOyBjaW4gPj4gdmFuOwogICAgICAgICAgICBjb3V0PDwiTmhhcCBkaWVtIHRpbjogIjsgY2luID4+IHRpbjsKICAgICAgICAgICAgY2luLmlnbm9yZSgpOwogICAgICAgICAgICBjb3V0PDxlbmRsOwogICAgICAgICAgICAKICAgICAgICB9CiAgICAgICAgdm9pZCB0aW5oKCl7CiAgICAgICAgICAgIHRvbmcgPSAodG9hbio0ICsgdmFuKjQgKyB0aW4qMikvMTA7CiAgICAgICAgICAgIGlmKHRvbmcgPj0gOSl7CiAgICAgICAgICAgICAgICB4ZXAgPSAiWHVhdCBzYWMiOwogICAgICAgICAgICB9ZWxzZQogICAgICAgICAgICAgICAgaWYodG9uZyA+PSA3LjUpewogICAgICAgICAgICAgICAgICAgIHhlcCA9ICJHaW9pIjsKICAgICAgICAgICAgICAgIH1lbHNlCiAgICAgICAgICAgICAgICAgICAgaWYodG9uZyA+PSA2KXsKICAgICAgICAgICAgICAgICAgICAgICAgeGVwID0gIktoYSI7CiAgICAgICAgICAgICAgICAgICB9ZWxzZQogICAgICAgICAgICAgICAgICAgIGlmKHRvbmcgPj0gNCl7CiAgICAgICAgICAgICAgICAgICAgICAgIHhlcCA9ICJUcnVuZyBiaW5oIjsKICAgICAgICAgICAgICAgICAgICB9ZWxzZQogICAgICAgICAgICAgICAgICAgICAgICBpZih0b25nIDwgNCl7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICB4ZXAgPSAiWWV1IjsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgCiAgICAgICAgfQoKICAgICAgICB2b2lkIHh1YXQoKXsKICAgICAgICAgICAgY291dDw8c2V0dygyMCk8PGxlZnQ8PHRlbgogICAgICAgICAgICA8PHNldHcoMTUpPDxsZWZ0PDxtc3Y7CiAgICAgICAgICAgIGlmKG5nPDEwKSBjb3V0PDwiMCI8PG5nPDwiLyI7CiAgICAgICAgICAgICAgICBlbHNlIGNvdXQ8PG5nPDwiLyI7CiAgICAgICAgICAgIGlmKHRoIDwgMTApIGNvdXQ8PCIwIjw8dGg8PCIvIjsKICAgICAgICAgICAgICAgIGVsc2UgY291dDw8bmFtPDwiLyI7CiAgICAgICAgICAgIGNvdXQ8PHNldHcoMTApPDxsZWZ0PDxuYW0KICAgICAgICAgICAgPDxzZXR3KDEwKTw8bGVmdDw8bmdhbmgKICAgICAgICAgICAgPDxzZXR3KDEzKTw8bGVmdDw8dG9uZwogICAgICAgICAgICA8PHNldHcoMTApPDxsZWZ0PDx4ZXA8PGVuZGw7CiAgICAgICAgfQogICAgICAgIGZsb2F0IGdldHRvbmcoKXsKICAgICAgICAgICAgcmV0dXJuIHRoaXMtPnRvbmc7CiAgICAgICAgfQogICAgICAgIGludCBnZXR0ZW4oKXsKICAgICAgICAgICAgcmV0dXJuIHRoaXMtPnRlbi5zaXplKCk7CiAgICAgICAgfQp9OwoKYm9vbCBjbXAoU1YgYSwgU1YgYil7CiAgICBpZihhLmdldHRvbmcoKSA8IGIuZ2V0dG9uZygpKSByZXR1cm4gYS5nZXR0b25nKCk7CiAgICAgICAgLy8gaWYoYS5nZXR0b25nKCkgPiBiLmdldHRvbmcoKSkgIHJldHVybiBiLmdldHRvbmcoKTsKICAgICAgICAvLyBlbHNlewogICAgaWYoYS5nZXR0b25nKCkgPT0gYi5nZXR0b25nKCkpewogICAgICA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