Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- string telephoneNumber;
- getline(cin, telephoneNumber);
- for (int i = 0; i < telephoneNumber.size(); i++)
- {
- char character = telephoneNumber[i];
- if(character == 'A' || character == 'B' || character == 'C') telephoneNumber[i] = '2';
- else if(character == 'D' || character == 'E' || character == 'F') telephoneNumber[i] = '3';
- else if(character == 'G' || character == 'H' || character == 'I') telephoneNumber[i] = '4';
- else if(character == 'J' || character == 'K' || character == 'L') telephoneNumber[i] = '5';
- else if(character == 'M' || character == 'N' || character == 'O') telephoneNumber[i] = '6';
- else if(character == 'P' || character == 'Q' || character == 'R' || character == 'S') telephoneNumber[i] = '7';
- else if(character == 'T' || character == 'U' || character == 'V') telephoneNumber[i] = '8';
- else if(character == 'W' || character == 'X' || character == 'Y' || character == 'Z') telephoneNumber[i] = '9';
- }
- cout << telephoneNumber << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement