Created
March 21, 2014 05:50
-
-
Save elgeish/9680291 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<map> | |
using namespace std; | |
map<char, int> t9; | |
void solve() { | |
char prev = -1, cur; | |
while((cur = cin.get()) != '\n') { | |
if (prev != -1 && t9[cur] % 10 == t9[prev] % 10) | |
cout << ' '; | |
cout << t9[cur]; | |
prev = cur; | |
} | |
} | |
int main() { | |
int freq[] = { 3, 3, 3, 3, 3, 4, 3, 4 }; | |
int key = 2, t = 1, N; | |
char c = 'a'; | |
for (int i = 0; i < 8; ++i, ++key) | |
for (int j = 1, code = key; j <= freq[i]; ++j, ++c, code = code * 10 + key) | |
t9[c] = code; | |
t9[' '] = 0; | |
cin >> N; cin.get(); | |
while (t <= N) | |
cout << "Case #" << t++ << ": ", solve(), cout << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment