10921 - Find the Telephone
Moderator: Board moderators
Re: 10921 - Find the Telephone
why do I have to read one character at a time? what's wrong with my current code?
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10921 - Find the Telephone
Try input Z output should be 9.
Check input and AC output for thousands of problems on uDebug!
Re: 10921 - Find the Telephone
Why WA?
But when I use scanf %s and a for loop, I got AC.
Code: Select all
AC, thanks brianfry. :D
Last edited by dibery on Wed Aug 28, 2013 8:09 am, edited 1 time in total.
Life shouldn't be null.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10921 - Find the Telephone
don't print an extra blank line at the end.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 20
- Joined: Wed Oct 30, 2013 7:06 pm
HashMap Runtime Error Java
solved
Last edited by Kenpachi24 on Wed Feb 12, 2014 10:33 am, edited 1 time in total.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: HashMap Runtime Error Java
For 11385, see http://acm.uva.es/board/viewtopic.php?t=27378
For 10921, at the end of the input you're calling trim() on a null pointer.
For 10921, at the end of the input you're calling trim() on a null pointer.
Check input and AC output for thousands of problems on uDebug!
-
- New poster
- Posts: 20
- Joined: Wed Oct 30, 2013 7:06 pm
Re: HashMap Runtime Error Java
Thank you for collaboration and share your knowledge, brianfry713
Re: 10921 - Find the Telephone
Why am I getting WA ? Anyone help plz.
Code: Select all
#include<stdio.h>
#include<string.h>
int main()
{
char msg[32];
int len,i;
while(scanf("%s",msg)==1){
len=strlen(msg);
i=0;
while(i<len){
if(msg[i]=='A'){
printf("2");
}
else if(msg[i]=='B'){
printf("2");
}
else if(msg[i]=='C'){
printf("2");
}
else if(msg[i]=='D'){
printf("3");
}
else if(msg[i]=='E'){
printf("3");
}
else if(msg[i]=='F'){
printf("3");
}
else if(msg[i]=='G'){
printf("4");
}
else if(msg[i]=='H'){
printf("4");
}
else if(msg[i]=='I'){
printf("4");
}
else if(msg[i]=='J'){
printf("5");
}
else if(msg[i]=='K'){
printf("5");
}
else if(msg[i]=='L'){
printf("5");
}
else if(msg[i]=='M'){
printf("6");
}
else if(msg[i]=='N'){
printf("6");
}
else if(msg[i]=='O'){
printf("6");
}
else if(msg[i]=='P'){
printf("7");
}
else if(msg[i]=='Q'){
printf("7");
}
else if(msg[i]=='R'){
printf("7");
}
else if(msg[i]=='S'){
printf("7");
}
else if(msg[i]=='T'){
printf("8");
}
else if(msg[i]=='U'){
printf("8");
}
else if(msg[i]=='V'){
printf("8");
}
else if(msg[i]=='W'){
printf("9");
}
else if(msg[i]=='X'){
printf("9");
}
else if(msg[i]=='Y'){
printf("9");
}
else if(msg[i]=='z'){
printf("9");
}
else{
printf("%c",msg[i]);
}
i++;
}
}
return 0;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10921 - Find the Telephone
Print a newline char at the end of each line.
Check input and AC output for thousands of problems on uDebug!