Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //uva 11530-sms typing
- #include<stdio.h>
- int main()
- {
- char type[100];
- int count,i,j,sum = 0,T;
- scanf("%d",&T);
- getchar();
- for(j=1; j<=T; j++)
- {
- sum = 0;
- gets(type);
- for(i=0; type[i] != '\0'; i++)
- {
- if(type[i] >= 'a' && type[i] <= 'c')
- {
- if(type[i] == 'a')
- count = 1;
- else if(type[i] == 'b')
- count = 2;
- else
- count = 3;
- }
- else if(type[i] >= 'd' && type[i] <= 'f')
- {
- if(type[i] == 'd')
- count = 1;
- else if(type[i] == 'e')
- count = 2;
- else
- count = 3;
- }
- else if(type[i] >= 'g' && type[i] <= 'i')
- {
- if(type[i] == 'g')
- count = 1;
- else if(type[i] == 'h')
- count = 2;
- else
- count = 3;
- }
- else if(type[i] >= 'j' && type[i] <= 'l')
- {
- if(type[i] == 'j')
- count = 1;
- else if(type[i] == 'k')
- count = 2;
- else
- count = 3;
- }
- else if(type[i] >= 'm' && type[i] <= 'o')
- {
- if(type[i] == 'm')
- count = 1;
- else if(type[i] == 'n')
- count = 2;
- else
- count = 3;
- }
- else if(type[i] >= 'p' && type[i] <= 's')
- {
- if(type[i] == 'p')
- count = 1;
- else if(type[i] == 'q')
- count = 2;
- else if(type[i] == 'r')
- count = 3;
- else
- count = 4;
- }
- else if(type[i] >= 't' && type[i] <= 'v')
- {
- if(type[i] == 't')
- count = 1;
- else if(type[i] == 'u')
- count = 2;
- else
- count = 3;
- }
- else if(type[i] >= 'w' && type[i] <= 'z')
- {
- if(type[i] == 'w')
- count = 1;
- else if(type[i] == 'x')
- count = 2;
- else if(type[i] == 'y')
- count = 3;
- else
- count = 4;
- }
- else if(type[i] == ' ')
- count = 1;
- sum = sum + count;
- }
- printf("Case #%d: %d\n",j,sum);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment