题解 | 成绩排序
成绩排序
https://www.nowcoder.com/practice/3f27a0a5a59643a8abf0140b9a8cf1f7
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int student[2][100] = { 0 };
int n;
while (cin >> n)
{
int point[100], student_temp[100] = { 0 };
for (int i = 0; i < n; i++)
cin >> student[0][i] >> student[1][i];
for (int i = 0; i < n; i++)
point[i] = student[1][i];
sort(point, point + n);
for (int i = 0; i < n; i++)
{
for (int j = n-1; j >= 0; j--)
{
if (point[i] == student[1][j] && student_temp[j] == 0)
{
cout << student[0][j] << " " << student[1][j] << endl;
student_temp[j] = 1;
break;
}
}
}
}
return 0;
}
OPPO公司福利 1225人发布