UVA : 11530 - SMS Typing
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
int i,count,test,l,j;
char a[110];
scanf("%d",&test);
getchar();
for(j=1;j<=test;j++){
gets(a);
l=strlen(a);
count=0;
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]==' '){
count++;
}
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'){
count+=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'){
count+=3;
}
else if(a[i]=='s'||a[i]=='z'){
count+=4;
}
}
printf("Case #%d: %d\n",j,count);
}
return 0;
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন