1. 程式人生 > >HustOJ - 1021

HustOJ - 1021

std truct img 技術 esp 亂碼 != using setw

技術分享
 1 #include<iostream>
 2 #include<vector>
 3 #include<algorithm>
 4 #include<string>
 5 #include<iomanip>
 6 using namespace std;
 7 //?á11ì?:
 8 struct student
 9 {
10     string S;
11     float s;
12 } stu;
13 bool myComp(const student &s1,const student &s2)
14
{ 15 if (s1.s!=s2.s) return s1.s>s2.s; 16 if (s1.S!=s2.S) return s1.S<s2.S; 17 }; 18 int main() 19 { 20 vector<float> ax; 21 vector<student> vx; 22 student zx; 23 int q,n,p; 24 float y; 25 float cj; 26 cin>>q; 27 for (int i=0; i<q; i++)
28 { 29 cin>>n; 30 for (int j=0; j<n; j++) 31 { 32 cin>>y; 33 ax.push_back(y); 34 } 35 cin>>p; 36 for(int k=0; k<p; k++) 37 { 38 cin >> zx.S; 39 y=0.0; 40 for
(int u=0; u<n; u++) 41 { 42 cin >> cj; 43 if (cj<60) continue; 44 y=y+(cj-50)/10 * ax[u]; 45 } 46 zx.s=y/10; 47 vx.push_back(zx); 48 } 49 cout<<"class "<<i+1<<":"<<endl; 50 sort(vx.begin(),vx.end(),myComp); 51 for (vector<student>::iterator vix=vx.begin();vix!=vx.end();vix++) 52 { 53 cout<<fixed<<setprecision(2); 54 cout<<left<<setw(11); 55 cout<<(*vix).S<<(*vix).s<<endl; 56 } 57 vx.clear(); 58 ax.clear(); 59 } 60 return 0; 61 }
1021 按績點排名

不知道為什麽,註釋亂碼了= =

HustOJ - 1021