... HAVE U TRIED .... AT LEAST 3 TIMES ... OK U CAN SEE THIS ...

Tuesday, December 24, 2013

UVA-11530 :: SMS Typing

#include <stdio.h>
int main ()
{
    int t , i ,r ,c ,p ,cnt ,cnt3 ,cnt2 ,cnt4 ,j ,x ;
    char  s [100],ch ;

    scanf ("%d\n",&t) ;

    for (i=1 ; i<=t ; i++)
    {
        // getchar () ;
        p=0 ;
        scanf("%c",&ch);
        //printf("%c ",ch);
        while (ch!='\n')
        {
            s [p] = ch ;
            scanf("%c",&ch);
            //printf("%c ",s[p]);
            p++ ;

        }
//printf("%c ",ch);
        cnt=0 ;
        cnt2 =0 ;
        cnt3 =0 ;
        cnt4 =0 ;
        for (j=0 ; j<= p ; j++)
        {
            if (s[j] == 'a' || s[j] == 'd'||s[j] == 'g' || s[j] == 'j'||s[j] == 'm' || s[j] == 'p'||s[j] == 't' || s[j] == 'w' ||s[j] == ' ') cnt ++ ;
            if (s[j] == 'b' || s[j] == 'e'||s[j] == 'h' || s[j] == 'k'||s[j] == 'n' || s[j] == 'q'||s[j] == 'u' || s[j] == 'x' ) cnt2 += 2 ;
            if  (s[j] == 'c' || s[j] == 'f'||s[j] == 'i' || s[j] == 'l'||s[j] == 'o' || s[j] == 'r'||s[j] == 'v' || s[j] == 'y' ) cnt3 += 3 ;
            if (s[j] == 's' || s[j] == 'z' ) cnt4 += 4 ;
        }

        x= cnt + cnt2 +cnt3 +cnt4 ;
        printf ("%d \n",x) ;

    }

}