Thursday 19 May 2011

acm 11530-SMS Typing

#include<stdio.h>
#include<stdlib.h>
int main()
{
    int t,nok=0,cases=1,i=0;char ch[101],tt[10];
    //freopen("in.txt","r",stdin);
    t=atoi(gets(tt));
    while(t--)
    {
        gets(ch);
        while(ch[i])
        {
            switch(ch[i])
            {
            case 'a':
            case 'd':
            case 'g':
            case 'j':
            case 'm':
            case 'p':
            case 't':
            case 'w':
                nok+=1;
                break;
            case 'b':
            case 'e':
            case 'h':
            case 'k':
            case 'n':
            case 'q':
            case 'u':
            case 'x':
                nok+=2;
                break;
            case 'c':
            case 'f':
            case 'i':
            case 'l':
            case 'o':
            case 'r':
            case 'v':
            case 'y':
                nok+=3;
                break;
            case 's':
            case 'z':
                nok+=4;
                break;
            default :
                nok+=1;
                break;
            }
            i++;
        }
        printf("Case #%d: %d\n",cases++,nok);
        i=nok=0;
    }
    return(0);
}

No comments:

Post a Comment