706 - LCD Display

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

Moderator: Board moderators

damihp
New poster
Posts: 4
Joined: Thu Jul 11, 2013 12:58 am

Re: 706 - LC-Display

Post by damihp » Wed Jul 24, 2013 8:44 am

Could anyone help me pls, im getting WA and im not sure why..

Thanks.

Code: Select all

Got accepted, thanks brian.
Last edited by damihp on Wed Jul 24, 2013 8:16 pm, edited 1 time in total.

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

Re: 706 - LC-Display

Post by brianfry713 » Wed Jul 24, 2013 11:50 am

Output a blank line after each number
Check input and AC output for thousands of problems on uDebug!

damihp
New poster
Posts: 4
Joined: Thu Jul 11, 2013 12:58 am

Re: 706 - LC-Display

Post by damihp » Wed Jul 24, 2013 8:15 pm

brianfry713 wrote:Output a blank line after each number
Thanks brian!!! =)

shikhorroy
New poster
Posts: 27
Joined: Sat Jul 27, 2013 3:52 am

706 - LCD Display(PE)

Post by shikhorroy » Mon Aug 05, 2013 5:42 pm

Presentation error......why???
Anyone can help me please...................

Code: Select all

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long int
#define sf scanf
#define pf printf
#define spc pf(" ")
#define bar pf("|")
#define sign pf("%c",'-')
#define nl pf("\n")
#define MAX 100
#define FOR(b,e) for(int i = b; i <= e; i++)
void layer1(char ch, int x){
    if(ch == '1' || ch == '4'){
        spc; FOR(1,x) spc; spc;
    }else{
        spc; FOR(1,x) sign; spc;
    }
}
void layer2(char ch,int x){
    if(ch == '0' || ch == '4' || ch == '8' || ch == '9'){
        bar; FOR(1,x) spc; bar;
    }else if(ch == '5' || ch == '6'){
        bar; FOR(1,x) spc; spc;
    }else{
        spc; FOR(1,x) spc; bar;
    }
}
void layer3(char ch,int x){
    if(ch == '0' || ch == '1' || ch == '7'){
        spc; FOR(1,x) spc; spc;
    }else{
        spc;FOR(1,x) sign; spc;
    }
}
void layer4(char ch,int x){
    if(ch == '0' || ch == '6' || ch == '8'){
        bar; FOR(1,x) spc; bar;
    }else if(ch == '2'){
        bar; FOR(1,x) spc; spc;
    }else{
        spc;FOR(1,x) spc; bar;
    }
}
void layer5(char ch, int x){
    if(ch == '1' || ch == '4' || ch == '7'){
        spc; FOR(1,x) spc; spc;
    }else{
        spc; FOR(1,x) sign; spc;
    }
}
int main()
{
    int s;
    char n[MAX];
    while(sf("%d%s",&s,n)){

        if(s == 0 && (!strcmp(n,"0")))  break;

        int l = strlen(n);

        for(int j = 0; j < l; j++){
            layer1(n[j],s); spc;
        }nl;
        for(int i = 0; i < s; i++){
            for(int j = 0; j < l; j++){
                layer2(n[j],s); spc;
            }nl;
        }
        for(int j = 0; j < l; j++){
            layer3(n[j],s); spc;
        }nl;
        for(int i = 0; i < s; i++){
            for(int j = 0; j < l; j++){
                layer4(n[j],s); spc;
            }nl;
        }
        for(int j = 0; j < l; j++){
            layer5(n[j],s); spc;
        }nl;
        nl;
    }
    return 0;
}

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

Re: 706 - LCD Display(PE)

Post by brianfry713 » Tue Aug 06, 2013 1:29 am

You're printing an extra space at the end of each line.
Check input and AC output for thousands of problems on uDebug!

shikhorroy
New poster
Posts: 27
Joined: Sat Jul 27, 2013 3:52 am

Re: 706 - LCD Display(PE)

Post by shikhorroy » Tue Aug 06, 2013 9:03 am

Hmmm....mmm....thanks.... :)

sampad74
New poster
Posts: 29
Joined: Wed Jun 18, 2014 3:57 pm
Location: Bangladesh

Re: 706 - LC-Display

Post by sampad74 » Sat Jun 21, 2014 1:06 pm

i got wa.please,help me to find out mistakes.
here is my code...
Last edited by sampad74 on Tue Jun 24, 2014 12:28 pm, edited 1 time in total.

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

Re: 706 - LC-Display

Post by brianfry713 » Mon Jun 23, 2014 10:06 pm

1 <= s <= 10
Check input and AC output for thousands of problems on uDebug!

sampad74
New poster
Posts: 29
Joined: Wed Jun 18, 2014 3:57 pm
Location: Bangladesh

Re: 706 - LC-Display

Post by sampad74 » Tue Jun 24, 2014 12:22 pm

sorry,i missed that.thanx brian fry

xiexinxinlove
New poster
Posts: 6
Joined: Thu Jul 10, 2014 2:19 pm

Uva 706,a easy problem,but WA!

Post by xiexinxinlove » Thu Jul 10, 2014 2:25 pm

When I tested the data, everything looks normal.Is there any special data can be used to test it?THX.

xiexinxinlove
New poster
Posts: 6
Joined: Thu Jul 10, 2014 2:19 pm

706 - LC-Display

Post by xiexinxinlove » Thu Jul 10, 2014 2:49 pm

I tested some of the data, it looks normal.But I got WA!Who can help me find the error?THX?This is my code?

Code: Select all

#include <stdio.h>
#include <string.h>
int main()
{
    int s,n;
    int i,j,k;
    int len;
    char a[15];
    while(scanf("%d",&s))
    {
        getchar();
        gets(a);
        len=strlen(a);
        if(s == 0 && a[0] == '0' && len == 1)
          break;
        //1?output line 1
        for(j=0; j<len; j++)
        {
            if(a[j] == '0' || a[j] == '2' || a[j] == '3' || a[j] == '5' || a[j] == '6' || a[j] == '7' || a[j] == '8' || a[j] == '9')
            {
                printf(" "); 
                for(k=1; k<=s; k++)
                {
                    printf("-"); 
                }
                printf(" ");
            }
            else if(a[j] == '1' || a[j] == '4')
            {
                for(k=1; k<=s+2; k++)
                {
                    printf(" "); 
                }
            } 
            if(a[j+1] != '\0')
              printf(" "); //Separated
        }
        printf("\n"); 
           
        //2?output line 2 ~ line s+1
        for(i=1; i<=s; i++)
        {
            for(j=0; j<len; j++)
            {
                if(a[j] == '1' || a[j] == '2' || a[j] == '3' || a[j] == '7')
                {
                    for(k=1; k<=s+1; k++)
                    {
                        printf(" ");
                    }
                    printf("|");
                }
                else if(a[j] == '5' || a[j] == '6')
                {
                    printf("|");
                    for(k=1; k<=s+1; k++)
                    {
                        printf(" ");
                    }
                }
                else if(a[j] == '4' || a[j] == '8' || a[j] == '9' || a[j] == '0')
                {
                    printf("|");
                    for(k=1; k<=s; k++)
                    {
                        printf(" ");
                    }
                    printf("|");
                }
                if(a[j+1] != '\0')
                 printf(" "); //Separated
            }
            printf("\n"); 
        }
        
        //3?output line s+2
        for(j=0; j<len; j++)
        {
            if(a[j] == '2' || a[j] == '3' || a[j] == '4' || a[j] == '5' || a[j] == '6' || a[j] == '8' || a[j] == '9')
            {

                printf(" ");
                for(k=1; k<=s; k++)
                {
                    printf("-");
                }
                printf(" ");
            }
            else if(a[j] == '0' || a[j] == '1' || a[j] == '7')
            {
                for(k=1; k<=s+2; k++)
                {
                    printf(" ");
                }
            }
            if(a[j+1] != '\0')
                 printf(" "); //Separated
        }
        printf("\n");
        
        //4?output line s+3 ~ line 2s+2 
        for(i=1; i<=s; i++)
        {
            for(j=0; j<len; j++)
            {
                if(a[j] == '1' || a[j] == '3' || a[j] == '4' || a[j] == '5' || a[j] == '7' || a[j] == '9')
                {
                    for(k=1; k<=s+1; k++)
                    {
                        printf(" ");
                    }
                    printf("|");
                }
                else if(a[j] == '0' || a[j] == '8' || a[j] == '6')
                {
                    printf("|");
                    for(k=1; k<=s; k++)
                    {
                        printf(" ");
                    }
                    printf("|");
                }
                else if(a[j] == '2')  
                {
                    printf("|");
                    for(k=1; k<=s+1; k++)
                    {
                        printf(" ");
                    }
                }  
            if(a[j+1] != '\0')
                 printf(" "); //Separated
            }
             printf("\n"); 
        }
        
        //5?output line 2s+3
        for(j=0; j<len; j++)
        {
            if(a[j] == '0' || a[j] == '2' || a[j] == '3' || a[j] == '5' || a[j] == '6' || a[j] == '8' || a[j] == '9')
            {
                printf(" ");
                for(k=1; k<=s; k++)
                {
                    printf("-");
                }
                printf(" ");
            }
            else if(a[j] == '1' || a[j] == '4' || a[j] == '7')
            {
                for(k=1; k<=s+2; k++)
                {
                    printf(" ");
                }
            }
            if(a[j+1] != '\0')
                 printf(" "); //Separated
        }
         printf("\n\n"); 
    }
    return 0;
}


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

Re: Uva 706,a easy problem,but WA!

Post by brianfry713 » Thu Jul 10, 2014 5:22 pm

Don't double post.
Check input and AC output for thousands of problems on uDebug!

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

Re: 706 - LC-Display

Post by brianfry713 » Thu Jul 10, 2014 6:55 pm

I changed your input parsing to this and got AC:
scanf("%d%d", &s, &n)
So perhaps there is extra whitespace or leading zeros that should be ignored.
Check input and AC output for thousands of problems on uDebug!

xiexinxinlove
New poster
Posts: 6
Joined: Thu Jul 10, 2014 2:19 pm

Re: Uva 706,a easy problem,but WA!

Post by xiexinxinlove » Fri Jul 11, 2014 6:12 am

I‘m sorry.

xiexinxinlove
New poster
Posts: 6
Joined: Thu Jul 10, 2014 2:19 pm

Re: 706 - LC-Display

Post by xiexinxinlove » Fri Jul 11, 2014 7:36 am

Thank you very much! brianfry713.
Last edited by xiexinxinlove on Mon Jul 14, 2014 3:12 pm, edited 2 times in total.

Post Reply

Return to “Volume 7 (700-799)”