您的位置:首页 > 其它

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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: