From e011c29db020a60c67f0dbc7a16faf129b3a6489 Mon Sep 17 00:00:00 2001 From: bala <13452927+rfgsdhshgfh@user.noreply.gitee.com> Date: Sat, 13 Jan 2024 16:11:20 +0000 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=AD=A6=E7=94=9F=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=9A=84=E5=A4=9A=E5=85=B3=E9=94=AE=E5=AD=97=E6=8E=92?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: bala <13452927+rfgsdhshgfh@user.noreply.gitee.com> --- ...6\345\255\227\346\216\222\345\272\217.cpp" | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 "2224020152/\347\254\254\345\215\201\345\215\225\345\205\203/\345\256\236\347\216\260\345\255\246\347\224\237\344\277\241\346\201\257\347\232\204\345\244\232\345\205\263\351\224\256\345\255\227\346\216\222\345\272\217.cpp" diff --git "a/2224020152/\347\254\254\345\215\201\345\215\225\345\205\203/\345\256\236\347\216\260\345\255\246\347\224\237\344\277\241\346\201\257\347\232\204\345\244\232\345\205\263\351\224\256\345\255\227\346\216\222\345\272\217.cpp" "b/2224020152/\347\254\254\345\215\201\345\215\225\345\205\203/\345\256\236\347\216\260\345\255\246\347\224\237\344\277\241\346\201\257\347\232\204\345\244\232\345\205\263\351\224\256\345\255\227\346\216\222\345\272\217.cpp" new file mode 100644 index 00000000..6f4581ac --- /dev/null +++ "b/2224020152/\347\254\254\345\215\201\345\215\225\345\205\203/\345\256\236\347\216\260\345\255\246\347\224\237\344\277\241\346\201\257\347\232\204\345\244\232\345\205\263\351\224\256\345\255\227\346\216\222\345\272\217.cpp" @@ -0,0 +1,33 @@ +#include +#include +#include +using namespace std; + +typedef struct student { + char name[20]; + int age, score; +}student; + +student s[105]; + +bool compare(student s1, student s2) { + if (s1.score != s2.score) + return s1.score > s2.score; + else if (strcmp(s1.name, s2.name) != 0) + return strcmp(s1.name, s2.name) < 0; + else + return s1.age < s2.age; +} + +int main() { + int n; + cin >> n; + for (int i = 0; i < n; ++i) { + cin >> s[i].name >> s[i].age >> s[i].score; + } + sort(s, s + n, compare); + for (int i = 0; i < n; ++i) { + cout << s[i].name << ' ' << s[i].age << ' ' << s[i].score << endl; + } + return 0; +} -- Gitee