新网创想网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C
- C Programming Language, M
- Mathematics (Calculus or Linear Algrbra), and E
- English. At the mean time, we encourage students by emphasizing on their best ranks -- that is, among the four ranks with respect to the three courses and the average grade, we print the best rank for each student.
For example, The grades of C
, M
, E
and A
- Average of 4 students are given as the following:
StudentID C M E A
310101 98 85 88 90
310102 70 95 88 84
310103 82 87 94 88
310104 91 91 91 91
Then the best ranks for all the students are No.1 since the 1st one has done the best in C Programming Language, while the 2nd one in Mathematics, the 3rd one in English, and the last one in average.
Input Specification:Each input file contains one test case. Each case starts with a line containing 2 numbers N and M (≤2000), which are the total number of students, and the number of students who would check their ranks, respectively. Then N lines follow, each contains a student ID which is a string of 6 digits, followed by the three integer grades (in the range of [0, 100]) of that student in the order of C
, M
and E
. Then there are M lines, each containing a student ID.
For each of the M students, print in one line the best rank for him/her, and the symbol of the corresponding rank, separated by a space.
The priorities of the ranking methods are ordered as A
>C
>M
>E
. Hence if there are two or more ways for a student to obtain the same best rank, output the one with the highest priority.
If a student is not on the grading list, simply output N/A
.
5 6
310101 98 85 88
310102 70 95 88
310103 82 87 94
310104 91 91 91
310105 85 90 90
310101
310102
310103
310104
310105
999999
Sample Output:1 C
1 M
1 E
1 A
3 A
N/A
我的代码
#include#include#includestruct student
{
char a[6];
int C,M,E,A;
};
struct pai
{
int ming;
char p;
};
int cmp(const void* a,const void* b){
if(((struct pai*)a)->ming-((struct pai*)b)->ming!=0){
return ((struct pai*)a)->ming-((struct pai*)b)->ming;
}else{
return ((struct pai*)a)->p-((struct pai*)b)->p;
}
}
main()
{
int n,m;
scanf("%d %d",&n,&m);
getchar();
struct student stu[n];
for(int i=0;istu[q].A){
rank++;
}
}
pp[0].ming=rank;
pp[0].p='a';
rank=1;
for(int j=0;jstu[q].C){
rank++;
}
}
pp[1].ming=rank;
pp[1].p='b';
rank=1;
for(int j=0;jstu[q].M){
rank++;
}
}
pp[2].ming=rank;
pp[2].p='c';
rank=1;
for(int j=0;jstu[q].E){
rank++;
}
}
pp[3].ming=rank;
pp[3].p='d';
qsort(pp,4,sizeof(pp[0]),cmp);
if(pp[0].p=='a'){
printf("%d A\n",pp[0].ming);
}else if(pp[0].p=='b'){
printf("%d C\n",pp[0].ming);
}else if(pp[0].p=='c'){
printf("%d M\n",pp[0].ming);
}else if(pp[0].p=='d'){
printf("%d E\n",pp[0].ming);
}
}
}
}
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧