Thursday, 10 May 2012
UVa 11530 SMS Typing Solution
#include<stdio.h>
#include<string.h>
int main()
{
int t,i,j,count,l;
char ch,s[120];
while(scanf("%d",&t)==1)
{
i=1;
while(i<=t)
{
gets(s);
l=strlen(s);
if(l==0) continue;
count=0;
for(j=0;j<l;j++)
{
switch(s[j])
{
case 'a':
case 'd':
case 'g':
case 'j':
case 'm':
case 'p':
case 't':
case 'w':
case ' ':
count=count+1;
break;
case 'b':
case 'e':
case 'h':
case 'k':
case 'n':
case 'q':
case 'u':
case 'x':
count=count+2;
break;
case 'c':
case 'f':
case 'i':
case 'l':
case 'o':
case 'r':
case 'v':
case 'y':
count=count+3;
break;
case 's':
case 'z':
count=count+4;
break;
}
}
printf("Case #%d: %d\n",i,count);
i++;
}
}
return 0;
}
Subscribe to:
Post Comments (Atom)
#include
ReplyDelete#include
int main()
{
int t,j,i;
int m=0;
char c,s;
scanf("%d",&t);
scanf("%c",&c);
while(t--)
{
char str[200];
gets(str);
int len=strlen(str);
int i,count=0;
for(i=0; i<len; i++)
{
if(str[i]=='a'||str[i]=='d'||str[i]=='g'||str[i]=='j'||str[i]=='m'||str[i]=='p'||str[i]=='t'||str[i]=='w'||str[i]==' ')
{
count=count+1;
}
else if(str[i]=='b'||str[i]=='e'||str[i]=='h'||str[i]=='k'||str[i]=='n'||str[i]=='q'||str[i]=='u'||str[i]=='x')
{
count=count+2;
}
else if(str[i]=='c'||str[i]=='f'||str[i]=='i'||str[i]=='l'||str[i]=='o'||str[i]=='r'||str[i]=='v'||str[i]=='y')
{
count=count+3;
}
else if(str[i]=='c'||str[i]=='f')
{
count=count+4;
}
}
printf("Case #%d: %d\n", ++m,count);
}
return 0;
}
codeblocks a input-output sob thik ase but uva te submit korle WA ase.kindly problem ta mark kore diten jodi