标签:des style blog class code java
Time Limit: 2000/1000 MS
(Java/Others) Memory Limit: 65536/32768 K
(Java/Others)
Total Submission(s): 14513 Accepted
Submission(s): 5318
1 #include<cstdio> 2 #include<cstring> 3 #include<cstdlib> 4 #include<vector> 5 #include<algorithm> 6 #include<functional> 7 #include<iostream> 8 using namespace std; 9 //设置一个简单的二级排序吧! 10 11 struct node 12 { 13 char no[25] ; 14 int grade; 15 bool operator < (const node &bb) const 16 { 17 if(grade==bb.grade) 18 { 19 return strcmp(no,bb.no)<0; 20 } 21 else return grade>bb.grade; //降序排列 22 } 23 }; 24 25 int mark[12]; 26 int main() 27 { 28 int n,m,g,i,num,tno; 29 vector<node>str; //将动态数组清零 30 node temp; 31 while(scanf("%d",&n),n) 32 { 33 str.clear(); 34 scanf("%d%d",&m,&g); 35 for(i=1;i<=m;i++) 36 scanf("%d",&mark[i]); 37 while(n--) 38 { 39 //学号 ,题目总数 40 scanf("%s%d",temp.no,&num); 41 temp.grade=0; //初始化为0 42 while(num--) 43 { 44 scanf("%d",&tno); 45 temp.grade+=mark[tno]; 46 } 47 if(temp.grade>=g) 48 str.push_back(temp); 49 } 50 if(str.empty()) printf("0\n"); 51 else 52 { 53 int length=str.size(); 54 printf("%d\n",length); 55 sort(str.begin(),str.end()); 56 for( i=0 ; i<length ; i++ ) 57 printf("%s %d\n",str[i].no,str[i].grade); 58 } 59 } 60 return 0; 61 }
HDUOJ---1236 排名(浙大考研题),布布扣,bubuko.com
标签:des style blog class code java
原文地址:http://www.cnblogs.com/gongxijun/p/3721154.html