1062. Talent and Virtue
来源:互联网 发布:苹果电脑数据恢复软件 编辑:程序博客网 时间:2024/05/16 23:40
题目链接:http://pat.zju.edu.cn/contests/pat-a-practise/1062
德才论:按给定分类,然后进行排序。
// 典型分类排序题#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include <ctype.h>#include <limits.h>#include <iostream>#include <algorithm>#include <vector>#include <string>#include <queue>#include <stack>#include <map>#include <set>#define SIZE 10000+10using namespace std;struct Node{int id;int virtue;int talent;int total;bool operator < (const Node& A) const{if(total != A.total){return total > A.total;}else if(virtue != A.virtue){return virtue > A.virtue;}else{return id < A.id;}}};vector<Node> sage;vector<Node> noble;vector<Node> fool;vector<Node> small;void output(vector<Node> v){for(int i=0; i<v.size(); i++){printf("%08d %d %d\n", v[i].id, v[i].virtue, v[i].talent);}}int main(){#ifdef ONLINE_JUDGE#elsefreopen("E:\\in.txt", "r", stdin);#endifint N, L, H;// inputscanf("%d%d%d", &N, &L, &H);while(N-->0){Node t;scanf("%d%d%d", &t.id, &t.virtue, &t.talent);t.total = t.virtue + t.talent;if(t.virtue >= L && t.talent >= L){if(t.virtue >= H && t.talent >= H){sage.push_back(t);}else if(t.virtue >= H && t.talent < H){noble.push_back(t);}else if(t.virtue < H && t.talent < H && t.virtue >= t.talent){fool.push_back(t);}else{small.push_back(t);}}}//outputprintf("%d\n", sage.size()+noble.size()+fool.size()+small.size());sort(sage.begin(), sage.end());output(sage);sort(noble.begin(), noble.end());output(noble);sort(fool.begin(), fool.end());output(fool);sort(small.begin(), small.end());output(small);return 0;}
0 0
- 1062. Talent and Virtue
- 1062. Talent and Virtue
- 1062.Talent and Virtue
- 1062. Talent and Virtue
- 1062. Talent and Virtue
- 1062. Talent and Virtue
- 1062. Talent and Virtue
- 1062. Talent and Virtue
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- PAT 1062. Talent and Virtue
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- 1062. Talent and Virtue (25)
- 服务器和客户端的通信绘图
- windows核心编程-线程调度,优先级和关联性
- 最大字段和——动态规划
- js模仿java的Map集合,实现功能
- 懒人果然是不行的
- 1062. Talent and Virtue
- 《软件工程核心知识》样章发布: 第2章--软件工程概论
- 人生不在于抓到一副好牌,而在于打好你手里的牌
- H264编码 封装成MP4格式 视频流 RTP封包
- NYOJ 982 Triangle Counting (数学题)
- HDU1262(解题报告)
- 黑马程序员---基础知识总结
- 笔记本怎么设置WIfi热点
- 1063. Set Similarity