Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include<string.h>
- using namespace std;
- int main()
- {
- char str[50];
- while(scanf("%s",&str)!=EOF)
- {
- int len=strlen(str);
- for(int i=0; i<len; i++)
- {
- if(str[i]=='-'||str[i]=='1'||str[i]=='0')
- {
- cout<<str[i];
- }
- else
- {
- switch(str[i])
- {
- case 'A' :
- case 'B' :
- case 'C' :
- cout<<"2";
- break;
- case 'D' :
- case 'E' :
- case 'F' :
- cout<<"3";
- break;
- case 'G' :
- case 'H' :
- case 'I' :
- cout<<"4";
- break;
- case 'J' :
- case 'K' :
- case 'L' :
- cout<<"5";
- break;
- case 'M' :
- case 'N' :
- case 'O' :
- cout<<"6";
- break;
- case 'P' :
- case 'Q' :
- case 'R' :
- case 'S' :
- cout<<"7";
- break;
- case 'T' :
- case 'U' :
- case 'V' :
- cout<<"8";
- break;
- case 'W' :
- case 'X' :
- case 'Y' :
- case 'Z' :
- cout<<"9";
- break;
- }
- }
- }
- cout<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment