日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

1012 The Best Rank (25)

發(fā)布時(shí)間:2024/7/19 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 1012 The Best Rank (25) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

題目描述:


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

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.

Output

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".

Sample Input
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<stdio.h> #include<algorithm> using namespace std;typedef struct stu { int id; int grade[4]; ? //grade[0]保存了平均數(shù)? }stu; int x; //x用于cmp判斷當(dāng)前比較哪門課的成績(jī)? bool cmp(stu a,stu b) { if(a.grade[x] != b.grade[x]) { return a.grade[x]>b.grade[x]; } } int compare1(stu arr[],int n,int Id) { int great=100,min,t,j; ?// great為最好的名次,t表示哪門課取得最好的名次? char y; for(int i = 0; i<4; i++) { x = i; sort(arr,arr+n,cmp); for( j = 0; j<n; j++) { if(arr[j].id == Id) { min = j+1; break; } } if(j == n) { printf("N/A\n"); return 0; } if(great>min) ? ? // 比較哪門課名次比較好? { great = min; t = x; } } if(t == 0) { y = 'A'; } else if( t == 1) { y = 'C'; } else if( t == 2) { y = 'M'; } else if( t == 3) { y = 'E'; } printf("%d %c\n",great,y); return 1; } int main(void) { int n,m,Id; scanf("%d%d",&n,&m); stu arr[n]; for(int i=0; i<n; i++) { scanf("%d%d%d%d",&arr[i].id,&arr[i].grade[1],&arr[i].grade[2],&arr[i].grade[3]); arr[i].grade[0] = (arr[i].grade[1]+arr[i].grade[2]+arr[i].grade[3])/3; } for(int i=0; i<m; i++) { scanf("%d",&Id); compare1(arr,n,Id); } }

總結(jié)

以上是生活随笔為你收集整理的1012 The Best Rank (25)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。