• uva 482


    <int, double> --> <int, string> 从而避免了输出格式;

     1 #include <vector>
     2 #include <string>
     3 #include <iostream>
     4 #include <sstream>
     5 #include <algorithm>
     6 using namespace std;
     7 
     8 int main()
     9 {
    10     int t, count = 0;
    11     string line1, line2;
    12     int index;
    13     string value;
    14     vector<pair<int, string>> store;
    15     cin >> t;
    16     getchar();
    17     while(t--)
    18     {
    19         getchar();
    20         count ++;
    21         getline(cin, line1);
    22         getline(cin, line2);
    23         stringstream ss1(line1), ss2(line2);
    24         while(ss1 >> index)
    25         {
    26             ss2 >> value;
    27             store.push_back(pair<int, string>(index, value));
    28         }
    29         sort(store.begin(), store.end());
    30         if(count > 1) cout << endl;
    31         for(int i = 0; i < store.size(); i++)
    32             cout << store[i].second << endl;
    33 
    34         store.clear();
    35     }
    36 
    37     return 0;
    38 }
     1 #include <iostream>
     2 #include <string>
     3 #include <sstream>
     4 #include <vector>
     5 #include <map>
     6 using namespace std;
     7 
     8 int main()
     9 {
    10     int T;
    11     cin >> T;
    12     while(T--)
    13     {
    14         string str, s;
    15         stringstream ss;
    16         vector<int> ind;
    17         map<int, string> Map;
    18 
    19         getline(cin, str); // T 后面的
    
    20         getline(cin, str); // 空行
    21 
    22         getline(cin, str); // index
    23         ss << str;
    24         while(ss >> s) ind.push_back(stoi(s));
    25 
    26         for(int i= 0;i < ind.size(); i++)
    27             cin >> str, Map[ind[i]] = str;
    28 
    29         for(int i = 0; i < ind.size(); i++)
    30                 cout << Map[i+1] << endl;
    31         if(T > 0)
    32             cout << endl;
    33     }
    34     return 0;
    35 }
    36 
    37 
    38 string toString(int I)
    39 {
    40     stringstream ss;
    41     string str;
    42     ss << I;
    43     ss >> str;
    44 
    45     return str;
    46 }
     1 // 输入输出是怎么回事???
     2 #include <iostream>
     3 #include <string>
     4 #include <sstream>
     5 #include <vector>
     6 #include <map>
     7 
     8 using namespace std;
     9 
    10 
    11 #define FOI(i, A, B) for(i = A; i <= B; i++)
    12 #define FOD(i, A, B) for(i = A; i >= b; i--)
    13 
    14 string toString(int I)
    15 {
    16     stringstream ss;
    17     string str;
    18     ss << I;
    19     ss >> str;
    20 
    21     return str;
    22 }
    23 
    24 int main()
    25 {
    26     int T;
    27     cin >> T;
    28     string str, s;
    29     while(T--)
    30     {
    31         getline(cin, str);
    32         getline(cin, str);
    33         vector<string> ind, val;
    34         map<string, string> Map;
    35         stringstream ss;
    36         getline(cin, str);
    37         ss << str;
    38         while(ss >> s) ind.push_back(s);
    39         int N = ind.size(), i;
    40         FOI(i, 0, N-1)
    41         {
    42             cin >> str;
    43             Map[ind[i]] = str;
    44         }
    45         FOI(i, 0, N-1)
    46                 cout << Map[toString(i+1)] << endl;
    47         if(T > 0)
    48             cout << endl;
    49     }
    50     return 0;
    51 }
  • 相关阅读:
    六种简单易理解的排序算法
    leetcode-數組篇
    leetcode-字符串篇
    java8 Optional优雅非空判断
    md2all 简单实用
    zooleeper面试题
    深入理解 JVM锁 与 分布式锁
    redission 高性能分布式锁
    Java传统 定时任务
    关于Zookeeper
  • 原文地址:https://www.cnblogs.com/aze-003/p/5161838.html
Copyright © 2020-2023  润新知