题目大意:给出N个考场的所有考生的信息,要求按照成绩排名,输出每个考生的 总排名、考场排名、和所在考场。
排序题,输入完每个考场的考生信息时,可以一次排序得到该考生的考场排名,输入完全部考场信息后再来一次排序,可以得到所有考生的总排名。
AC代码:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
struct student
{
string id;
int score;
int finalRank;
int localRank;
int location;
student(string id, int score, int location):id(id), score(score), location(location){};
bool operator< (const student &other)
{
if(this->score != other.score) return this->score > other.score;
return this->id < other.id;
}
};
int main()
{
int N;
cin >> N;
vector<student> totalStu;
for (int i = 1; i <= N; ++i)
{
int K;
cin >> K;
vector<student> v;
for (int j = 0; j < K; ++j)
{
string id, score

博客详细解析了PAT A1025题目的内容,主要涉及排序算法的应用。通过输入考场及考生信息,计算并输出每个考生的总排名、考场排名和所在考场。博主提供了AC代码实现这一功能。
最低0.47元/天 解锁文章
778

被折叠的 条评论
为什么被折叠?



