PAT甲级1083 List Grades:[C++题解]结构体、排序
文章目录
- 题目分析
- 题目链接
题目分析
来源:acwing
分析: 结构体存下来所有信息。根据成绩存入vector,然后排序输出即可。
ac代码
#include<bits/stdc++.h>
using namespace std;
const int N = 110;
struct Person{string name ,id;int grade;bool operator< (const Person& t)const{return grade > t. grade;}
}p[N];
int main(){int n;cin >> n;for(int i = 0; i<n ; i++ ){string name,id;int grade;cin>> p[i].name >> p[i].id >> p[i].grade;}int a, b;cin >> a >> b;vector<Person> res;for(int i= 0; i<n ;i ++){if(p[i].grade>= a && p[i].grade <=b) res.push_back(p[i]);}if(res.empty()) cout<<"NONE"<<endl;else{sort(res.begin(),res.end());for(auto s:res) cout<< s.name <<" " << s.id<<endl;}
}
题目链接
PAT甲级1083 List Grades
https://www.acwing.com/problem/content/1571/
PAT甲级1083 List Grades:[C++题解]结构体、排序相关推荐
- PAT甲级1141 PAT Ranking of Institutions :[C++题解]结构体、排序、哈希表、结构体构造函数、结构体内写函数、排名
文章目录 题目分析 题目来源 题目分析 来源:acwing 分析:和下面这题是一道题: PAT甲级1137 Final Grading:[C++题解]结构体.排序.哈希表.结构体构造函数.结构体内写函 ...
- PAT甲级真题(结构体排序)——1012. The Best Rank (25)
1012. The Best Rank (25) To evaluate the performance of our first year CS majored students, we consi ...
- Monkey and Banana HDU - 1069 [ 结构体排序+DP最长不上升子序列 ] 详细题解
题解目录 1.题目 2.题意 3.思路 4.代码 1.题目 A group of researchers are designing an experiment to test the IQ of a ...
- qvector 结构体排序_C++结构体的应用_YCOJ
结构体是一种自定义的东西,用struct来定义.在他里面, 可以装许多东西,比如int,string,char,bool等等等等. 如: struct a{ string name; int a; i ...
- 还是贪心(结构体排序)
2128: 盾神与积木游戏 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 127 Solved: 39 [Submit][Status][Web Boa ...
- sort对结构体排序
1.排序方法: sort(数组起始指针,数组尾指针,排序规则); 数组起始指针,数组尾指针是左闭右开 排序规则可以省略,也可以用系统的,也可以自己写 2.例子: int a[]={9,2,4,5,10 ...
- P1068 分数线划定 洛谷 (C++)(结构体排序)
简单的结构体排序,代码如下 #include <iostream> #include <cstdio> #include <algorithm> #include ...
- C#中结构体排序方法(Array.sort() + ICompare)
感觉C#比C++麻烦许多,资料也少,找了半天竟然没有找到一个能用的结构体排序. 这是待排序的结构体: public struct la{public int id;public int sb;}; 首 ...
- 【HDU】1862 EXCEL排序(结构体排序)
Problem Description Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能. Input 测试输入包含若干测试用例.每个测试用例的第1行包含两个整数 N (<= ...
最新文章
- pyqt5动态删除控件问题
- Codeforces Round #377 (Div. 2) 732A B C D E F
- Innodb中MySQL如何快速删除2T的大表
- [pytorch、学习] - 3.13 丢弃法
- webdriver鼠标上下滑动
- bs架构 erp 进销存_从应用架构看生鲜电商信息化建设
- 操作系统之I/O管理:2、I/O软件层次结构
- sysbench的框架实现介绍
- Bootstrap进度条堆叠
- m7405d粉盒清零方法_联想打印机计数器怎么清零?一体机硒鼓怎么清零?看这一篇就够...
- struts2:表单标签
- GitHub 添加 SSH keys
- r语言作业:出租车数据基础数据分析、时间处理等
- Sql Prompt使用技巧
- 智慧树源码_知到智慧树_网课查题网站源码_答案章节作业期末答案
- Django DTL 加减乘除求余
- xj膜你赛(n-1)
- 高中数学基础-2.1.1(1)根式的运算
- offer_II_109开密码锁
- calendar 5 android版,Calendars 5 by Readdle