zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    在MAC系统的eclipse里打开android sdk manager
    在MAC上搭建eclipse+android开发环境以及eclipse的svn插件的安装
    C语言入门
    变量和数据类型
    兼容 FF&IE 的替换鼠标选择文字方法(转载)
    JavaScript 中在光标处插入添加文本标签节点 详细方法
    jquery获取鼠标位置
    转:javascript Range对象跨浏览器常用操作
    日省三思
    jQuery强大的jQuery选择器 (详解)[转]
  • 原文地址:https://www.cnblogs.com/aze-003/p/5161838.html
Copyright © 2011-2022 走看看