![:)](./images/smilies/icon_smile.gif)
11530 - SMS Typing
Moderator: Board moderators
Re: 11530 - SMS Typing
Can anyone give some sample test cases? That would be real helpful! ![:)](./images/smilies/icon_smile.gif)
![:)](./images/smilies/icon_smile.gif)
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11530 - SMS Typing
Try running your code on the sample input.
Check input and AC output for thousands of problems on uDebug!
Re: 11530 - SMS Typing
@brianfry713 I did!! The output is the the same.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11530 - SMS Typing
Check input and AC output for thousands of problems on uDebug!
Re: 11530 - sms typing -- Why WA???? :(
http://ideone.com/fnbbmb whats wrong with this? please anyone help ![:(](./images/smilies/icon_frown.gif)
![:(](./images/smilies/icon_frown.gif)
Re: 11530 - sms typing -- Why WA???? :(
Change this
This way is more safe
Code: Select all
scanf(" %d ", &n);
Code: Select all
scanf("%d", &n);
while(getchar() != '\n') ;
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11530 - sms typing -- Why WA???? :(
As lighted pointed out, your code won't work if the second line begins with a space.
Check input and AC output for thousands of problems on uDebug!
Re: 11530 - sms typing -- Why WA???? :(
yeah! i got it.. thanks guys.. ![:)](./images/smilies/icon_smile.gif)
![:)](./images/smilies/icon_smile.gif)
-
- New poster
- Posts: 32
- Joined: Tue Jul 22, 2014 1:17 am
11530 - SMS Typing
{'O''K'}
Last edited by ehsanulbigboss on Thu Aug 14, 2014 4:22 pm, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11530 - SMS Typing
There is a newline char after T
Check input and AC output for thousands of problems on uDebug!
Re: 11530 - SMS Typing
why WA ?i dont understand
Code: Select all
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
string array1="adgjmptw ",array2="behknqux",array3="cfilorvy";
string s;
cin>>t;
int c=1;
for(int i=0; i<t; i++)
{
scanf(" ");
getline(cin,s);
int sum=0;
for(int j=0; s[j]; j++)
{
for(int k=0; k<9; k++)
if(s[j]==array1[k])
{
sum += 1;
break;
}
for(int k=0; k<8; k++)
if(s[j]==array2[k])
{
sum += 2;
break;
}
for(int k=0; k<8; k++)
if(s[j]==array3[k])
{
sum += 3;
break;
}
if(s[j]=='s' || s[j]=='z')
sum += 4;
}
printf("Case #%d: %d\n",c++,sum);
}
return 0;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11530 - SMS Typing
Don't use scanf(" "); on line 12. Try adding a getline() after you read T.
Check input and AC output for thousands of problems on uDebug!