这题怎么写啊(外网)
  • 板块灌水区
  • 楼主LSR120218_juruo
  • 当前回复4
  • 已保存回复4
  • 发布时间2024/2/26 23:05
  • 上次更新2024/2/27 15:21:15
查看原帖
这题怎么写啊(外网)
971101
LSR120218_juruo楼主2024/2/26 23:05

题目传送

代码:

#include <iostream>
using namespace std;

struct clas {
	int Student_ID;
	char name;
	char score;
};

int main() {
	struct clas a[101], t;
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i].Student_ID >> a[i].name >> a[i].score;
	}
	for (int i = 1; i <= n - 1; i++) {
		for (int j = 1; j <= n - i; j++) {
			if (a[j].score < a[j + 1].score) {
				t = a[j];
				a[j] = a[j + 1];
				a[j + 1] = t;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << a[i].Student_ID << " " << a[i].name << " " << a[i].score << endl;
	}

	return 0;
}

请各位大佬帮忙看一下,谢谢

本人蒟蒻,勿喷

2024/2/26 23:05
加载中...