当前位置:网站首页>Pat class a 1028 list sorting
Pat class a 1028 list sorting
2022-07-03 07:42:00 【IX. is it a non random title】
Be careful vector sort Use
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
typedef struct _student{
string ID;
string name;
int score;
}student;
bool compare1(const student &h, const student &k){
if(h.ID < k.ID) return true;
else return false;
}
bool compare2(const student &h, const student &k){
if(h.name < k.name) return true;
else if(h.name == k.name){
if(h.ID < k.ID) return true;
else return false;
}
else return false;
}
bool compare3(const student &h, const student &k){
if(h.score < k.score) return true;
else if(h.score == k.score){
if(h.ID < k.ID) return true;
else return false;
}
else return false;
}
int main(int argc, char **argv){
int i, j, a, c, m, n;
cin>>m>>n;
vector<student> v;
student stt;
for(i = 0; i < m; i++){
cin>>stt.ID>>stt.name>>stt.score;
v.push_back(stt);
}
if(n==1) sort(v.begin(), v.end(), compare1);
else if(n==2) sort(v.begin(), v.end(), compare2);
else sort(v.begin(), v.end(), compare3);
for(i = 0; i < m; i++)
cout<<v[i].ID<<" "<<v[i].name<<" "<<v[i].score<<endl;
return EXIT_SUCCESS;
}边栏推荐
- 【开发笔记】基于机智云4G转接板GC211的设备上云APP控制
- 技术干货|昇思MindSpore可变序列长度的动态Transformer已发布!
- How long is the fastest time you can develop data API? One minute is enough for me
- 【MySQL 12】MySQL 8.0.18 重新初始化
- 技术干货|昇思MindSpore算子并行+异构并行,使能32卡训练2420亿参数模型
- The babbage industrial policy forum
- 截图工具Snipaste
- Vertx restful style web router
- Application of pigeon nest principle in Lucene minshouldmatchsumscorer
- 【LeetCode】4. Best Time to Buy and Sell Stock·股票买卖最佳时机
猜你喜欢

Go language foundation ----- 06 ----- anonymous fields, fields with the same name

Traversal in Lucene

Go language foundation ----- 02 ----- basic data types and operators
![[mindspire paper presentation] summary of training skills in AAAI long tail problem](/img/34/9c9ec1b94edeecd4a3e7f20fdd8356.png)
[mindspire paper presentation] summary of training skills in AAAI long tail problem

Analysis of the problems of the 10th Blue Bridge Cup single chip microcomputer provincial competition

技术干货|昇思MindSpore NLP模型迁移之LUKE模型——阅读理解任务
![[Development Notes] cloud app control on device based on smart cloud 4G adapter gc211](/img/55/fea5fe315932b92993d21f861befbe.png)
[Development Notes] cloud app control on device based on smart cloud 4G adapter gc211

Technical dry goods Shengsi mindspire elementary course online: from basic concepts to practical operation, 1 hour to start!

Go language foundation ----- 13 ----- file

Go language foundation ------ 14 ------ gotest
随机推荐
The concept of C language pointer
PAT甲级 1031 Hello World for U
技术干货|昇思MindSpore创新模型EPP-MVSNet-高精高效的三维重建
Go language foundation ------ 14 ------ gotest
【LeetCode】4. Best Time to Buy and Sell Stock·股票买卖最佳时机
The difference between typescript let and VaR
OSPF experiment
Logging log configuration of vertx
Qtip2 solves the problem of too many texts
Technical dry goods Shengsi mindspire innovation model EPP mvsnet high-precision and efficient 3D reconstruction
go语言-循环语句
Go language foundation ----- 02 ----- basic data types and operators
【MySQL 13】安装MySQL后第一次修改密码,可以可跳过MySQL密码验证进行登录
What did the DFS phase do
項目經驗分享:實現一個昇思MindSpore 圖層 IR 融合優化 pass
Vertx's responsive redis client
【开发笔记】基于机智云4G转接板GC211的设备上云APP控制
Comparison of advantages and disadvantages between most complete SQL and NoSQL
Application of pigeon nest principle in Lucene minshouldmatchsumscorer
Technical dry goods | alphafold/ rosettafold open source reproduction (2) - alphafold process analysis and training Construction
https://github.com/ZouJiu1/PAT