Page 2 of 2

Re: 10921 - Find the Telephone

Posted: Mon Mar 11, 2013 5:27 pm
by CyberPunk
why do I have to read one character at a time? what's wrong with my current code?

Re: 10921 - Find the Telephone

Posted: Mon Mar 11, 2013 10:39 pm
by brianfry713
Try input Z output should be 9.

Re: 10921 - Find the Telephone

Posted: Tue Aug 27, 2013 6:24 pm
by dibery
Why WA?

Code: Select all

AC, thanks brianfry. :D
But when I use scanf %s and a for loop, I got AC.

Re: 10921 - Find the Telephone

Posted: Tue Aug 27, 2013 10:51 pm
by brianfry713
don't print an extra blank line at the end.

HashMap Runtime Error Java

Posted: Sat Feb 08, 2014 10:19 pm
by Kenpachi24
solved

Re: HashMap Runtime Error Java

Posted: Wed Feb 12, 2014 12:26 am
by brianfry713
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.

Re: HashMap Runtime Error Java

Posted: Wed Feb 12, 2014 10:36 am
by Kenpachi24
Thank you for collaboration and share your knowledge, brianfry713

Re: 10921 - Find the Telephone

Posted: Wed Feb 11, 2015 6:44 pm
by nhimran
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;
}

Re: 10921 - Find the Telephone

Posted: Wed Feb 11, 2015 10:39 pm
by brianfry713
Print a newline char at the end of each line.