Uva solution 10921 Find the Telephone

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int d;
    char ch[1000];
    while(!cin.getline(ch,1000).eof())
    {
        d=strlen(ch);
        for(int i=0; i<d; i++)
        {
            if(ch[i]=='1')
            {
                cout<<1;
            }
            if(ch[i]=='0')
            {
                cout<<0;
            }
            if(ch[i]=='-')
            {
                cout<<"-";
            }
            if(ch[i]=='A' || ch[i]=='B' || ch[i]=='C')
            {
                cout<<2;
            }
            if(ch[i]=='D' || ch[i]=='E' || ch[i]=='F')
            {
                cout<<3;
            }
            if(ch[i]=='G' || ch[i]=='H' || ch[i]=='I')
            {
                cout<<4;
            }
            if(ch[i]=='J' || ch[i]=='K' || ch[i]=='L')
            {
                cout<<5;
            }
            if(ch[i]=='M' || ch[i]=='N' || ch[i]=='O')
            {
                cout<<6;
            }
            if(ch[i]=='P' || ch[i]=='Q' || ch[i]=='R' || ch[i]=='S')
            {
                cout<<7;
            }
            if(ch[i]=='T' || ch[i]=='U' || ch[i]=='V')
            {
                cout<<8;
            }
            if(ch[i]=='W' || ch[i]=='X' || ch[i]=='Y' || ch[i]=='Z')
            {
                cout<<9;
            }
        }
        cout<<endl;
    }
}

Comments

Popular posts from this blog

Codeforces Solution 230B T-primes

Uri Solution 2747 Output 1