当前位置:网站首页>PAT甲级 1028 List Sorting
PAT甲级 1028 List Sorting
2022-07-03 07:34:00 【九是否非随机的称呼】
注意vector sort的使用
#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;
}边栏推荐
- VMware virtual machine installation
- Project experience sharing: Based on mindspore, the acoustic model is realized by using dfcnn and CTC loss function
- Leetcode 213: looting II
- Download address collection of various versions of devaexpress
- Traversal in Lucene
- How long is the fastest time you can develop data API? One minute is enough for me
- 【MySQL 11】怎么解决MySQL 8.0.18 大小写敏感问题
- 项目经验分享:基于昇思MindSpore,使用DFCNN和CTC损失函数的声学模型实现
- PgSQL converts string to double type (to_number())
- Mail sending of vertx
猜你喜欢
![[coppeliasim4.3] C calls UR5 in the remoteapi control scenario](/img/ca/2f72ea3590c358a6c9884aaa1a1c33.png)
[coppeliasim4.3] C calls UR5 in the remoteapi control scenario

图像识别与检测--笔记

技术干货|昇思MindSpore NLP模型迁移之Bert模型—文本匹配任务(二):训练和评估

Leetcode 198: house raiding

Homology policy / cross domain and cross domain solutions /web security attacks CSRF and XSS

Common methods of file class

《指環王:力量之戒》新劇照 力量之戒鑄造者亮相

Qtip2 solves the problem of too many texts
![[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

不出网上线CS的各种姿势
随机推荐
Grpc message sending of vertx
2021-07-18
Hello world of vertx
圖像識別與檢測--筆記
Lucene introduces NFA
Common operations of JSP
截图工具Snipaste
Jeecg request URL signature
C code production YUV420 planar format file
Jeecg data button permission settings
Technical dry goods Shengsi mindspire lite1.5 feature release, bringing a new end-to-end AI experience
项目经验分享:基于昇思MindSpore实现手写汉字识别
[mindspire paper presentation] summary of training skills in AAAI long tail problem
HISAT2 - StringTie - DESeq2 pipeline 进行bulk RNA-seq
Jeecg menu path display problem
Industrial resilience
技术干货|利用昇思MindSpore复现ICCV2021 Best Paper Swin Transformer
Segment read
[set theory] Stirling subset number (Stirling subset number concept | ball model | Stirling subset number recurrence formula | binary relationship refinement relationship of division)
New stills of Lord of the rings: the ring of strength: the caster of the ring of strength appears
https://github.com/ZouJiu1/PAT