Uva-11530 - SMS Typing
Problem link:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=2525
Solution:
#include<stdio.h>
int main(void){
int main(void){
int t,i=1,sum=0;
char a,b;
scanf("%d",&t);
scanf("%c",&b);
while(i<=t){
while(scanf("%c",&a)==1){
if(a=='\n'){
printf("Case #%d: %d\n",i,sum);
sum=0;
break;
}
switch(a){
case'a':
case'd':
case'g':
case'j':
case'm':
case'p':
case't':
case'w':
sum=sum+1;
break;
case'b':
case'e':
case'h':
case'k':
case'n':
case'q':
case'u':
case'x':
sum=sum+2;
break;
case 'c':
case'f':
case'i':
case'l':
case'o':
case'r':
case'v':
case'y':
sum=sum+3;
break;
case's':
case'z':
sum=sum+4;
break;
default:
sum=sum+1;
break;
}
}
i++;
}
return 0;
}
No comments:
Post a Comment