首页 > 学院 > 开发设计 > 正文

1025

2019-11-14 10:02:02
字体:
来源:转载
供稿:网友
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;struct Testee{char regNum[15];int score;int locNum;int finalRank;int localRank;}Tes[30020];bool cmp(Testee a,Testee b){if (a.score != b.score)return a.score > b.score;elsereturn strcmp(a.regNum, b.regNum) < 0;}int main(){int N;scanf("%d", &N);int location = 1;int base = 0;while (location <= N){int k;scanf("%d", &k);for (int i = 0; i < k; i++){scanf("%s %d", Tes[i + base].regNum, &Tes[i + base].score);Tes[i + base].locNum = location;}sort(Tes+base, Tes+base + k, cmp);int rank = 1;for (int i = 0; i < k; i++){if (i == 0 || Tes[base+i].score != Tes[base+i-1].score){Tes[base+i].localRank = rank;}elseTes[base + i].localRank = Tes[base + i - 1].localRank;rank++;}base += k;location++;}sort(Tes, Tes + base, cmp);int rank = 1;for (int i = 0; i < base; i++){if (i == 0 || Tes[i].score != Tes[i - 1].score){Tes[i].finalRank = rank;}elseTes[i].finalRank = Tes[i - 1].finalRank;rank++;}PRintf("%d/n", base);for (int i = 0; i < base; i++){printf("%s %d %d %d/n", Tes[i].regNum, Tes[i].finalRank, Tes[i].locNum, Tes[i].localRank);}return 0;}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表