#include <iostream> using namespace std; int main() { int n; // 读取学生总人数 cin >> n; int scores[100]; // 读取n个学生的成绩 for (int i = 0; i < n; i++) { cin >> scores[i]; } int x; // 读取小明的成绩 cin >> x; int rank = 1; // 遍历所有成绩 for (int i = 0; i < n; i++) { if (scores[i] > x) { // 若有比小明成绩高的,排名加1 rank++; } } // 输出小明的排名 cout << rank << endl; return 0; } 代码解释 /************************************************************** Problem: 1399 User: fuyijun Language: C++ Result: Compile Error ****************************************************************/