10921 - Find the Telephone

All about problems in Volume 109. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

CyberPunk
New poster
Posts: 7
Joined: Sat Mar 02, 2013 11:11 pm

Re: 10921 - Find the Telephone

Post by CyberPunk » Mon Mar 11, 2013 5:27 pm

why do I have to read one character at a time? what's wrong with my current code?

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10921 - Find the Telephone

Post by brianfry713 » Mon Mar 11, 2013 10:39 pm

Try input Z output should be 9.
Check input and AC output for thousands of problems on uDebug!

dibery
Learning poster
Posts: 76
Joined: Sat Feb 23, 2013 4:16 pm
Location: Taiwan, Taipei
Contact:

Re: 10921 - Find the Telephone

Post by dibery » Tue Aug 27, 2013 6:24 pm

Why WA?

Code: Select all

AC, thanks brianfry. :D
But when I use scanf %s and a for loop, I got AC.
Last edited by dibery on Wed Aug 28, 2013 8:09 am, edited 1 time in total.
Life shouldn't be null.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10921 - Find the Telephone

Post by brianfry713 » Tue Aug 27, 2013 10:51 pm

don't print an extra blank line at the end.
Check input and AC output for thousands of problems on uDebug!

Kenpachi24
New poster
Posts: 20
Joined: Wed Oct 30, 2013 7:06 pm

HashMap Runtime Error Java

Post by Kenpachi24 » Sat Feb 08, 2014 10:19 pm

solved
Last edited by Kenpachi24 on Wed Feb 12, 2014 10:33 am, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: HashMap Runtime Error Java

Post by brianfry713 » Wed Feb 12, 2014 12:26 am

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.
Check input and AC output for thousands of problems on uDebug!

Kenpachi24
New poster
Posts: 20
Joined: Wed Oct 30, 2013 7:06 pm

Re: HashMap Runtime Error Java

Post by Kenpachi24 » Wed Feb 12, 2014 10:36 am

Thank you for collaboration and share your knowledge, brianfry713

nhimran
New poster
Posts: 2
Joined: Wed Feb 11, 2015 6:35 pm

Re: 10921 - Find the Telephone

Post by nhimran » Wed Feb 11, 2015 6:44 pm

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;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10921 - Find the Telephone

Post by brianfry713 » Wed Feb 11, 2015 10:39 pm

Print a newline char at the end of each line.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 109 (10900-10999)”