#include <iostream>
#include <string>
#include <algorithm>
#include <list>
using namespace std;
struct Student {
string id;
string name;
int score;
string remark;
};
bool compareByScore(const Student &a, const Student &b) {
return a.score < b.score;
}
int main() {
list<Student> students;
// 输入学生信息
// ...
// 输出学生信息
for (const auto &student : students) {
cout << "学号:" << student.id << ",姓名:" << student.name << ",成绩:" << student.score << ",备注:" << student.remark << endl;
}
// 查询给定分数以上的学生信息
int givenScore = 80;
for (const auto &student : students) {
if (student.score >= givenScore) {
cout << "学号:" << student.id << ",姓名:" << student.name << ",成绩:" << student.score << ",备注:" << student.remark << endl;
}
}
// 按分数排序
students.sort(compareByScore);
for (const auto &student : students) {
cout << "学号:" << student.id << ",姓名:" << student.name << ",成绩:" << student.score << ",备注:" << student.remark << endl;
}
// 使用宏交换两个值
int a = 5, b = 10;
#define SWAP(x, y) { int temp = x; x = y; y = temp; }
SWAP(a, b);
cout << "a: " << a << ", b: " << b << endl;
return 0;
}