Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
108920 彭士宝 18删除成绩 C++ Accepted 1 MS 276 KB 693 2025-01-23 16:22:15

Tests(10/10):


Code:

#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; // 读取班级中学生的数量 vector<int> scores(n); // 创建一个向量来存储成绩 for (int i = 0; i < n; ++i) { cin >> scores[i]; // 读取每个学生的成绩 } int delIndex; cin >> delIndex; // 读取需要删除的学生学号 // 删除指定学号的学生成绩 if (delIndex >= 1 && delIndex <= n) { scores.erase(scores.begin() + delIndex - 1); } // 输出剩余学生的成绩 for (int score : scores) { cout << score << " "; } cout << endl; // 输出换行 return 0; }