当前位置:网站首页>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;
}边栏推荐
- PdfWriter. GetInstance throws system Nullreferenceexception [en] pdfwriter GetInstance throws System. NullRef
- URL programming
- Analysis of the problems of the 12th Blue Bridge Cup single chip microcomputer provincial competition
- An overview of IfM Engage
- 技术干货|昇思MindSpore算子并行+异构并行,使能32卡训练2420亿参数模型
- Responsive MySQL of vertx
- Read config configuration file of vertx
- IndexSort
- New stills of Lord of the rings: the ring of strength: the caster of the ring of strength appears
- Analysis of the problems of the 10th Blue Bridge Cup single chip microcomputer provincial competition
猜你喜欢

TCP cumulative acknowledgement and window value update

Image recognition and detection -- Notes

Technical dry goods Shengsi mindspire innovation model EPP mvsnet high-precision and efficient 3D reconstruction

Common methods of file class

【MySQL 14】使用DBeaver工具远程备份及恢复MySQL数据库(Linux 环境)

VMWare网络模式-桥接,Host-Only,NAT网络

【MindSpore论文精讲】AAAI长尾问题中训练技巧的总结

Wireshark software usage
![[set theory] Stirling subset number (Stirling subset number concept | ball model | Stirling subset number recurrence formula | binary relationship refinement relationship of division)](/img/d8/b4f39d9637c9886a8c81ca125d6944.jpg)
[set theory] Stirling subset number (Stirling subset number concept | ball model | Stirling subset number recurrence formula | binary relationship refinement relationship of division)

Analysis of the problems of the 11th Blue Bridge Cup single chip microcomputer provincial competition
随机推荐
II. D3.js draw a simple figure -- circle
The underlying mechanism of advertising on websites
IO stream system and FileReader, filewriter
截图工具Snipaste
The babbage industrial policy forum
Leetcode 213: 打家劫舍 II
TypeScript let与var的区别
Chrome 98 Private Network Access problem w/ disabled web security: Request had no target IP address
技术干货|昇思MindSpore算子并行+异构并行,使能32卡训练2420亿参数模型
技术干货|昇思MindSpore可变序列长度的动态Transformer已发布!
Use of generics
Project experience sharing: Based on mindspore, the acoustic model is realized by using dfcnn and CTC loss function
技术干货|昇思MindSpore NLP模型迁移之LUKE模型——阅读理解任务
Lucene merge document order
Comparison of advantages and disadvantages between most complete SQL and NoSQL
項目經驗分享:實現一個昇思MindSpore 圖層 IR 融合優化 pass
Circuit, packet and message exchange
哪一刻你才发现青春结束了
技术干货|昇思MindSpore创新模型EPP-MVSNet-高精高效的三维重建
技术干货|昇思MindSpore Lite1.5 特性发布,带来全新端侧AI体验
https://github.com/ZouJiu1/PAT