pat 1062
来源:互联网 发布:美发免费收银软件 编辑:程序博客网 时间:2024/06/03 14:27
#include<stdio.h>#include<vector>#include<algorithm>#include<string.h>using namespace std;struct person{ char id[10]; int virtue, talent;};bool cmp(struct person a, struct person b){ if (a.virtue + a.talent == b.virtue + b.talent) if (a.virtue == b.virtue) return strcmp(a.id, b.id)<=0; else return b.virtue <a.virtue; else return b.virtue + b.talent < (a.virtue + a.talent);}int main(){ freopen("1.in", "r", stdin); int n,low,high; scanf("%d%d%d", &n, &low, &high); struct person *stu = new struct person[n]; vector<struct person> sages, foolman, nobleman, rest; int i,count = 0; for (i = 0; i < n; i++){ scanf("%s%d%d", &stu[i].id, &stu[i].virtue, &stu[i].talent); if (stu[i].virtue < low||stu[i].talent < low){ count++; continue; } else if (stu[i].virtue >= high&&stu[i].talent >= high) sages.push_back(stu[i]); else if (stu[i].virtue >= high&&stu[i].talent < high) nobleman.push_back(stu[i]); else if (stu[i].virtue < high&&stu[i].talent <= stu[i].virtue) foolman.push_back(stu[i]); else rest.push_back(stu[i]); } printf("%d\n", n - count); vector<struct person>::iterator k; sort(sages.begin(), sages.end(), cmp); for (k = sages.begin(); k != sages.end(); k++) printf("%s %d %d\n", (*k).id, (*k).virtue, (*k).talent); sort(nobleman.begin(), nobleman.end(), cmp); for (k = nobleman.begin(); k != nobleman.end(); k++) printf("%s %d %d\n", (*k).id, (*k).virtue, (*k).talent); sort(foolman.begin(), foolman.end(), cmp); for (k = foolman.begin(); k != foolman.end(); k++) printf("%s %d %d\n", (*k).id, (*k).virtue, (*k).talent); sort(rest.begin(), rest.end(), cmp); for (k = rest.begin(); k != rest.end(); k++) printf("%s %d %d\n", (*k).id, (*k).virtue, (*k).talent); return 0;}
0 0
- pat 1062
- pat 1062
- PAT 1062
- PAT(甲级)1062
- 浙大PAT甲级 1062
- PAT甲级1062
- PAT乙级1062
- pat-bl-1062
- PAT乙级1062
- PAT 1062最简分数
- PAT basic 1062
- pat
- 【PAT】
- PAT
- PAT
- PAT
- PAT
- PAT
- 5 Component属性
- 《数据结构编程实验》 1.1.1Financial Management
- requestWindowFeature使用详解
- IO中同步、异步与阻塞、非阻塞的区别
- Drupal
- pat 1062
- (hdu step 4.1.8)猜数字(求n次所能猜到的最大数字)
- poj 2686 状态dp
- linux应用程序如何运行
- 沉浸式状态栏
- oracle错误代码
- 骨牌铺方格
- IT常用英语
- poj 2411 Mondriaan's Dream 状压dp入门