当前位置:网站首页>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;
}边栏推荐
- Various postures of CS without online line
- 微软安全响应中心
- 技术干货|昇思MindSpore可变序列长度的动态Transformer已发布!
- IndexSort
- Technology dry goods | luxe model for the migration of mindspore NLP model -- reading comprehension task
- 技术干货|昇思MindSpore算子并行+异构并行,使能32卡训练2420亿参数模型
- 【MySQL 11】怎么解决MySQL 8.0.18 大小写敏感问题
- Paper learning -- Study on the similarity of water level time series of Xingzi station in Poyang Lake
- Technical dry goods Shengsi mindspire operator parallel + heterogeneous parallel, enabling 32 card training 242 billion parameter model
- Why is data service the direction of the next generation data center?
猜你喜欢

Hnsw introduction and some reference articles in lucene9

The concept of C language pointer

項目經驗分享:實現一個昇思MindSpore 圖層 IR 融合優化 pass
![[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

Comparison of advantages and disadvantages between most complete SQL and NoSQL

Go language foundation ----- 01 ----- go language features

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

Go language foundation ----- 05 ----- structure

技术干货|昇思MindSpore算子并行+异构并行,使能32卡训练2420亿参数模型

Analysis of the problems of the 7th Blue Bridge Cup single chip microcomputer provincial competition
随机推荐
Technical dry goods | hundred lines of code to write Bert, Shengsi mindspire ability reward
Go language foundation ------ 12 ------ JSON
华为交换机基础配置(telnet/ssh登录)
opensips与对方tls sip trunk对接注意事项
华为S5700交换机初始化和配置telnet,ssh用户方法
HarmonyOS第三次培训笔记
Lombok cooperates with @slf4j and logback to realize logging
SQL create temporary table
Go language foundation ----- 09 ----- exception handling (error, panic, recover)
技术干货|昇思MindSpore算子并行+异构并行,使能32卡训练2420亿参数模型
Vertx multi vertical shared data
Go language foundation ------17 ----- channel creation, read-write, security shutdown, multiplexing select
Go language foundation ----- 11 ----- regular expression
华为S5700交换机初始化和配置SSH和TELNET远程登录方法
图像识别与检测--笔记
Lucene hnsw merge optimization
Industrial resilience
Analysis of the eighth Blue Bridge Cup single chip microcomputer provincial competition
[set theory] order relation (partial order relation | partial order set | example of partial order set)
TypeScript let与var的区别
https://github.com/ZouJiu1/PAT