UVA-11530 SMS Typing
#include<stdio.h>
int main()
{
char a[100];
int n,i,j,total,k=1;
scanf("%d",&n);
char enter=getchar();
for(j=0;j<n;j++)
{
int sum=0,sum1=0,sum2=0,sum3=0;
gets(a);
int l=strlen(a);
for(i=0;i<=l;i++)
{
if(a[i]=='a'||a[i]=='d'||a[i]=='g'||a[i]=='j'||a[i]=='m'||a[i]=='p'||a[i]=='t'||a[i]=='w'||a[i]==' ')
{
sum=sum+1;
}
else if(a[i]=='b'||a[i]=='e'||a[i]=='h'||a[i]=='k'||a[i]=='n'||a[i]=='q'||a[i]=='u'||a[i]=='x')
{
sum1=sum1+2;
}
else if(a[i]=='c'||a[i]=='f'||a[i]=='i'||a[i]=='l'||a[i]=='o'||a[i]=='r'||a[i]=='v'||a[i]=='y')
{
sum2=sum2+3;
}
else if(a[i]=='s'||a[i]=='z')
{
sum3=sum3+4;
}
total=sum+sum1+sum2+sum3;
}
printf("Case #%d: %d\n",k,total);
k++;
}
return 0;
}
No comments:
Post a Comment