// UVa 10921 - Find the Telephone #include <iostream> #include <string> using namespace std; int main() { string st; while (cin >> st) { for (int i = 0; i < st.size(); i++) if (st[i] >= 'A' && st[i] <= 'Z') { int o = st[i] - 'A'; int n; if (o < 15) n = o / 3 + 2; else { o = o - 15; if (o < 4) n = 7; else if (o < 7) n = 8; else if (o < 11) n = 9; } st[i] = '0' + n; } cout << st << endl; } return 0; }
No comments:
Post a Comment