Advertisement
welel33t

telephone

Mar 2nd, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8.     string telephoneNumber;
  9.     getline(cin, telephoneNumber);
  10.  
  11.     for (int i = 0; i < telephoneNumber.size(); i++)
  12.     {
  13.         char character = telephoneNumber[i];
  14.         if(character == 'A' || character == 'B' || character == 'C') telephoneNumber[i] = '2';
  15.         else if(character == 'D' || character == 'E' || character == 'F') telephoneNumber[i] = '3';
  16.         else if(character == 'G' || character == 'H' || character == 'I') telephoneNumber[i] = '4';
  17.         else if(character == 'J' || character == 'K' || character == 'L') telephoneNumber[i] = '5';
  18.         else if(character == 'M' || character == 'N' || character == 'O') telephoneNumber[i] = '6';
  19.         else if(character == 'P' || character == 'Q' || character == 'R' || character == 'S') telephoneNumber[i] = '7';
  20.         else if(character == 'T' || character == 'U' || character == 'V') telephoneNumber[i] = '8';
  21.         else if(character == 'W' || character == 'X' || character == 'Y' || character == 'Z') telephoneNumber[i] = '9';
  22.     }
  23.  
  24.     cout << telephoneNumber << endl;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement