1042. Shuffling Machine (20)
2015-08-29 16:42
239 查看
思路: 将数据存储到结构体数组 后按照给定的顺序排序
#include<iostream> #include<vector> #include<cmath> #include<string> #include<cstring> #include<algorithm> #include<iomanip> #include<map> using namespace std; #define Max 10000 struct node { string S; int N; }Hash[55]; bool cmp(node n1, node n2) { return n1.N<n2.N; } void Fun() { for(int i=1; i<=9; i++) { Hash[i].S="S"; Hash[i].S+=i+'0'; } Hash[10].S="S10"; Hash[11].S="S11"; Hash[12].S="S12"; Hash[13].S="S13"; for(int i=14, j=1; i<=22; i++, j++) { Hash[i].S="H"; Hash[i].S+=j+'0'; } Hash[23].S="H10"; Hash[24].S="H11"; Hash[25].S="H12"; Hash[26].S="H13"; for(int i=27, j=1; i<=35; i++, j++) { Hash[i].S="C"; Hash[i].S+=j+'0'; } Hash[36].S="C10"; Hash[37].S="C11"; Hash[38].S="C12"; Hash[39].S="C13"; for(int i=40, j=1; i<=48; i++, j++) { Hash[i].S="D"; Hash[i].S+=j+'0'; } Hash[49].S="D10"; Hash[50].S="D11"; Hash[51].S="D12"; Hash[52].S="D13"; Hash[53].S="J1"; Hash[54].S="J2"; } int main() { Fun(); int K, arr[55]; cin>>K; for(int i=1; i<55; i++) cin>>arr[i]; while(K--) { for(int i=1; i<55; i++) Hash[i].N=arr[i]; sort(Hash+1, Hash+55, cmp); } for(int i=1; i<55; i++){ if(i>1) cout<<" "; cout<<Hash[i].S; } cout<<endl; return 0; }
相关文章推荐
- 虚拟内存及虚拟文件系统概论
- Odoo8.0 模块开发方法
- php SPL学习
- php自带的几个防止sql注入的函数
- 利用注册表优化系统,减少开机时间
- 1059 -- Picture
- 浅谈L0,L1,L2范数及其应用
- IOS-笔记18(Core Motion,Core Location,Map Kit)
- LeetCode(258) Add Digits
- c-free中hashtable问题
- ex14
- 1058 -- 货币兑换
- 1057 -- 评委打分
- 高效率地安排见面会
- powershell玩转litedb数据库
- Java单链表的实现
- linux中的bpf封包
- ANT 领风格说明
- mmu内存管理单元
- 1056 -- 三点顺序