• 482 Permutation Arrays


    C++语言: Codee#25769
    01 /*
    02 +++++++++++++++++++++++++++++++++++++++
    03             author: chm
    04 +++++++++++++++++++++++++++++++++++++++
    05 */
    06
    07
    08 #include <map>
    09 #include <set>
    10 #include <list>
    11 #include <queue>
    12 #include <cmath>
    13 #include <stack>
    14 #include <bitset>
    15 #include <cstdio>
    16 #include <cctype>
    17 #include <string>
    18 #include <vector>
    19 #include <cassert>
    20 #include <cstdlib>
    21 #include <cstring>
    22 #include <fstream>
    23 #include <sstream>
    24 #include <iomanip>
    25 #include <iostream>
    26 #include <algorithm>
    27
    28 using namespace std;
    29
    30 FILE*            fin         = stdin;
    31 FILE*            fout         = stdout;
    32 const int        max_size     = 10086;
    33
    34 struct Tp
    35 {
    36     int idx;
    37     char str[99];
    38     Tp(int x, char* source)
    39     {
    40         idx = x;
    41         strcpy(str, source);
    42     }
    43 };
    44
    45 bool mycmp(Tp x, Tp y)
    46 {
    47     return x.idx < y.idx;
    48 }
    49
    50 int main()
    51 {
    52     int n;
    53     int num;
    54     int cnt;
    55     char tmp[max_size];
    56     vector<Tp> vtr;
    57
    58     while(scanf("%d\n\n", &n) != EOF)
    59     {
    60         for(int i = 0; i < n; ++i)
    61         {
    62             vtr.clear();
    63             cin.getline(tmp, sizeof(tmp));
    64             string line(tmp);
    65             istringstream is(line);
    66             cnt = 0;
    67
    68             while(is >> num)
    69             {
    70                 ++cnt;
    71                 vtr.push_back(Tp(num, ""));
    72             }
    73             for(int j = 0; j < cnt; ++j)            //read
    74                 cin >> vtr[j].str;
    75             sort(vtr.begin(), vtr.end(), mycmp);    //sort
    76             for(int j = 0; j < cnt; ++j)            //print
    77                 cout << vtr[j].str << endl;
    78             if(i < n - 1)
    79             {
    80                 cout << endl;
    81                 scanf("\n");
    82             }
    83
    84         }
    85     }
    86     return 0;
    87 }
  • 相关阅读:
    ansible笔记(11):初识ansible playbook(二)
    Linux下查看占用CPU与内存最高的进程
    ansible笔记(10):初识ansible playbook
    AbpZero Http 模式下 Chrome浏览器因Cookie 不能登录
    Tomcat 8443&8080 并存
    接入腾讯cos文件存储
    安卓包打渠道标签
    java Android与PHP encode的区别
    thinkphp常用
    phalcon task任务
  • 原文地址:https://www.cnblogs.com/invisible/p/2389870.html
Copyright © 2020-2023  润新知