PAT_ 1055. The World's Richest
来源:互联网 发布:sqlyog怎么写sql语句 编辑:程序博客网 时间:2024/05/23 01:13
//// main.cpp// PAT_ 1055. The World's Richest//// Created by wjq on 17/5/15.// Copyright © 2017年 wjq. All rights reserved.//#include <iostream>#include <algorithm>using namespace std;struct record{ string name; int age,worths;}r[100005];int N,K,outputnum,Amin,Amax;char str[10];int cmpall(record a,record b){ if(a.worths==b.worths) { if(a.age==b.age) return a.name<b.name; else return a.age<b.age; } else return a.worths>b.worths;}int main(int argc, const char * argv[]){ scanf("%d%d",&N,&K); for(int i=0;i<N;i++) { scanf("%s%d%d",str,&r[i].age,&r[i].worths); r[i].name=str; } sort(r,r+N,cmpall); for(int i=0;i<K;i++) { scanf("%d%d%d",&outputnum,&Amin,&Amax); int temp=outputnum; cout<<"Case #"<<i+1<<":"<<endl; for(int j=0;j<N&&temp!=0;j++) { if(r[j].age>=Amin&&r[j].age<=Amax&&temp--) cout<<r[j].name<<" "<<r[j].age<<" "<<r[j].worths<<endl; } if(temp==outputnum) cout<<"None"; } return 0;}
pat常见套路题,排序.
阅读全文
0 0
- PAT_ 1055. The World's Richest
- 浙江大学PAT_甲级_1055. The World's Richest (25)
- 1055. The World's Richest
- 1055.The World's Richest
- 1055. The World's Richest
- 1055. The World's Richest
- 1055. The World's Richest
- 【PAT】1055. The World's Richest (25)
- pat 1055. The World's Richest (25)
- pat 1055. The World's Richest (25)
- 1055. The World's Richest (25)
- <PAT>1055. The World's Richest
- 1055. The World's Richest (25)
- 1055. The World's Richest (25)
- PAT 1055. The World's Richest
- 【待修改】1055. The World's Richest
- 1055. The World's Richest (25)
- PAT: 1055. The World's Richest (25)
- 字符字面量及字符串的特点
- UVA-11796-计算几何
- 那些年企业类型项目的一些总结
- 《笨笨数据压缩教程第二章》边读边转给有需要的朋友...
- struts2中拦截器(interceptor)的简单配置
- PAT_ 1055. The World's Richest
- 关于KMP算法中next函数的详细解析
- OBB包围盒
- 离散题目3
- 机器学习常见算法简单介绍
- Visual Studio 2017 与Python
- POJ 1135 Domino Effect 笔记
- .net网站项目的aspx.cs文件修改无用
- python 高级特性之迭代器