Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

10082 finished

  • Loading branch information...
commit 9c1577fec22c38aee460bb605315a90c281c95ad 1 parent 0712a39
kharus authored March 30, 2012

Showing 1 changed file with 77 additions and 10 deletions. Show diff stats Hide diff stats

  1. 87  10082/10082.cc
87  10082/10082.cc
... ...
@@ -1,22 +1,89 @@
1 1
 #include<iostream>
2 2
 #include<string>
3 3
 #include<map>
  4
+#include<vector>
  5
+
  6
+using namespace std;
  7
+
  8
+string convert(const string& original);
  9
+map<char,char> get_conversion_table();
4 10
 
5 11
 int main(){
6  
-  std::string line;
7  
-  std::string result;
8  
-  std::map<char,char> conversion_table;
  12
+  string line;
  13
+  vector<string> results;
  14
+  
  15
+  do {
  16
+    getline(cin, line);
  17
+    results.push_back(convert(line));
  18
+  } while (!line.empty());
9 19
 
10  
-  conversion_table['W'] = 'Q';
11  
-  getline(std::cin, line);
  20
+  results.pop_back();
  21
+
  22
+  for(int i=0; i<results.size(); i++){
  23
+    cout<<results[i]<<endl;
  24
+  }
  25
+}
12 26
 
13  
-  for(int i=0; i<line.size(); i++){
14  
-    if (conversion_table.count(line[i])==1){
15  
-      result.push_back(conversion_table[line[i]]);
  27
+string convert(const string& original){
  28
+  string result;
  29
+  map<char,char> conversion_table = get_conversion_table();
  30
+
  31
+  for(int i=0; i<original.size(); i++){
  32
+    if (conversion_table.count(original[i])==1){
  33
+      result.push_back(conversion_table[original[i]]);
16 34
     } else {
17  
-      result.push_back(line[i]);
  35
+      result.push_back(original[i]);
18 36
     }
19 37
   }
  38
+  return result;
  39
+}
  40
+
  41
+map<char,char> get_conversion_table() {
  42
+  map<char,char> conversion_table;  
  43
+
  44
+  conversion_table['W'] = 'Q';
  45
+  conversion_table['E'] = 'W';
  46
+  conversion_table['R'] = 'E';
  47
+  conversion_table['T'] = 'R';
  48
+  conversion_table['Y'] = 'T';
  49
+  conversion_table['U'] = 'Y';
  50
+  conversion_table['I'] = 'U';
  51
+  conversion_table['O'] = 'I';
  52
+  conversion_table['P'] = 'O';
  53
+  conversion_table['['] = 'P';
  54
+  conversion_table[']'] = '[';
  55
+  conversion_table['\\'] = ']';
  56
+  conversion_table['1'] = '`';
  57
+  conversion_table['2'] = '1';
  58
+  conversion_table['3'] = '2';
  59
+  conversion_table['4'] = '3';
  60
+  conversion_table['5'] = '4';
  61
+  conversion_table['6'] = '5';
  62
+  conversion_table['7'] = '6';
  63
+  conversion_table['8'] = '7';
  64
+  conversion_table['9'] = '8';
  65
+  conversion_table['0'] = '9';
  66
+  conversion_table['-'] = '0';
  67
+  conversion_table['='] = '-';
  68
+  conversion_table['S'] = 'A';
  69
+  conversion_table['D'] = 'S';
  70
+  conversion_table['F'] = 'D';
  71
+  conversion_table['G'] = 'F';
  72
+  conversion_table['H'] = 'G';
  73
+  conversion_table['J'] = 'H';
  74
+  conversion_table['K'] = 'J';
  75
+  conversion_table['L'] = 'K';
  76
+  conversion_table[';'] = 'L';
  77
+  conversion_table['\''] = ';';
  78
+  conversion_table['X'] = 'Z';
  79
+  conversion_table['C'] = 'X';
  80
+  conversion_table['V'] = 'C';
  81
+  conversion_table['B'] = 'V';
  82
+  conversion_table['N'] = 'B';
  83
+  conversion_table['M'] = 'N';
  84
+  conversion_table[','] = 'M';
  85
+  conversion_table['.'] = ',';
  86
+  conversion_table['/'] = '.';
20 87
 
21  
-  std::cout<<result<<std::endl;
  88
+  return conversion_table;
22 89
 }

0 notes on commit 9c1577f

Please sign in to comment.
Something went wrong with that request. Please try again.