阅读背景:

poj 1298 The Hardest Problem Ever

来源:互联网 
//第一次竟然因为map的映射中写错了一个而WA了一次,哎,粗心! 
#include "iostream"
#include "string"
#include "map"
#include "cctype"
using namespace std;

map<char, char> m;

int main()
{  
    m['A'] = 'V', m['B'] = 'W', m['C'] = 'X', m['D'] = 'Y', m['E'] = 'Z',
    m['F'] = 'A', m['G'] = 'B', m['H'] = 'C', m['I'] = 'D', m['J'] = 'E',
    m['K'] = 'F', m['L'] = 'G', m['M'] = 'H', m['N'] = 'I', m['O'] = 'J',
    m['P'] = 'K', m['Q'] = 'L', m['R'] = 'M', m['S'] = 'N', m['T'] = 'O',
    m['U'] = 'P', m['V'] = 'Q', m['W'] = 'R', m['X'] = 'S', m['Y'] = 'T', m['Z'] = 'U'; 
    string input, ans;
    int len, i;
    while (1)
    {
          getline(cin, input);
          if (input == "START" || input == "END") continue;
          if (input == "ENDOFINPUT") break;
          ans.clear();
          len = input.length();
          for (i = 0; i < len; i++)
          {
              if (isalpha(input[i]))
                 ans.push_back(m[input[i]]);
              else
                 ans.push_back(input[i]);
          }
          cout << ans << endl;
    }
    
    system("pause");
}
//第一次竟然因为map的映射中写错了一个而WA了一次,哎,粗心! 
#include "io



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: