首页 > 试题广场 >

成绩排序

[编程题]成绩排序
  • 热度指数:22993 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
有N个学生的数据,将学生数据按成绩从低到高排序,如果成绩相同则按姓名字符的字典序由小到大排序,如果姓名的字典序也相同则按照学生的年龄从小到大排序,并输出N个学生排序后的信息。

输入描述:
测试数据有多组,每组输入第一行有一个整数N(N<=1000),接下来的N行包括N个学生的数据。
每个学生的数据包括姓名(长度不超过100的字符串)、年龄(整形数)、成绩(小于等于100的正数)。


输出描述:
将学生信息按成绩进行排序,成绩相同的则按姓名的字母序进行排序。
然后输出学生信息,按照如下格式:
姓名 年龄 成绩

学生姓名的字母序区分字母的大小写,如A要比a的字母序靠前(因为A的ASC码比a的ASC码要小)。
示例1

输入

3
abc 20 99
bcd 19 97
bed 20 97

输出

bcd 19 97
bed 20 97
abc 20 99
头像 潇尘
发表于 2021-03-17 22:38:12
大致思路就是按照题目要求设置一下sort函数的cmp参数 #include <iostream> #include <algorithm> #include <string> using namespace std; typedef struct { st 展开全文
头像 在考古的小鱼干很有气魄
发表于 2023-03-07 09:39:29
#include <bits/stdc++.h> #define MAX 1000 using namespace std; typedef struct student { string name; int age; int grade; } student; 展开全文
头像 nzxkc
发表于 2022-02-12 00:50:27
//结构体重载运算符即可 #include<iostream> #include<algorithm> #include<cstring> #include<vector> using namespace std; int&nbs 展开全文
头像 牛客929439239号
发表于 2022-09-21 15:42:57
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct Stu {     cha 展开全文
头像 在做毕设的鲸鱼很刻苦
发表于 2023-03-05 22:39:40
#include <algorithm> #include <iostream> using namespace std; struct Student { string name; int age; int grade; }; Student st 展开全文
头像 给我就亿下
发表于 2023-03-14 11:44:41
#include <iostream> #include <algorithm> using namespace std; struct Student{ string name; int age; int score; }; const int MAXN = 10 展开全文
头像 燃烧的橘子
发表于 2023-03-09 21:47:34
#include <iostream> #include<vector> #include<algorithm> using namespace std; struct student { string name; int age; in 展开全文
头像 Mamba_Back
发表于 2022-01-19 12:51:59
#include using namespace std; typedef struct stu { string name; int age; int score; }stu, * s; s scoresort(s sheet, int num) { for (int i = 0; i < 展开全文
头像 bigbigcake
发表于 2024-03-23 08:43:52
#include <iostream> #include <algorithm> #include <vector> using namespace std; class person{ public: int score; 展开全文
头像 木何
发表于 2023-03-04 20:41:10
#include<iostream> #include<algorithm> #include<cstring> using namespace std; typedef struct student { string name; int ag 展开全文

问题信息

难度:
111条回答 12139浏览

热门推荐

通过挑战的用户

查看代码