#include<bits/stdc++.h>
using namespace std;
struct Stu{ char n[15]; int q, t;}s[10001];
int main(){
int Q, T, cnt = 0, t, err;
char tmp[100];
scanf("%d %d", &Q, &T);
while(scanf("%s", s[cnt+1].n) == 1){//输入结束的标志
cnt++;
for(int i = 1; i <= Q; i++){
scanf("%s", tmp);
if(tmp[0] != '-' && tmp[0] != '0'){
s[cnt].q++;
if(sscanf(tmp, "%d(%d)", &t, &err) == 2){ // 格式化输入
s[cnt].t += T*err;
}
s[cnt].t += t;
}
}
}
sort(s+1, s+cnt+1, [](Stu x, Stu y){
if(x.q == y.q){
if(x.t == y.t) return strcmp(x.n, y.n) < 0;
return x.t < y.t;
}
return x.q > y.q;
});
for(int i = 1; i <= cnt; i++){
printf("%-10s %2d %4d\n",s[i].n, s[i].q, s[i].t);//%-10s 表示左对齐10个字符宽
}
return 0;
}
//sscanf sscanf的作用:从一个字符串中读进于指定格式相符的数据。
//利用它可以从字符串中取出整数、浮点数和字符串。
06-05
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交