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

zero
New poster
Posts: 5
Joined: Sat Apr 26, 2003 7:23 pm

706 i can't figure it out

Post by zero »

\ :evil:
i tried all data on my pc and it is right
but i still got a WA
please help me

i've considered
0 case
blanks

what else did i miss??

Farid Ahmadov
Experienced poster
Posts: 131
Joined: Thu Apr 17, 2003 8:39 am
Location: Baku, Azerbaijan

Post by Farid Ahmadov »

Give me some of your inputs and output exactly as your program generates and I'll try to help you to fix your mistake.
_____________
NO sigNature

zero
New poster
Posts: 5
Joined: Sat Apr 26, 2003 7:23 pm

Post by zero »

thanks so much
but i alreaky found the problem

however, i don't understand why the question would appear.
because i declared a global variable : char a[10][4][3]
and initialize each element in a sub function
everything is right in the sub func
but at once leave the sub func-- a[5][0][0] would disappear
therefore i should initialize it again in the main function

it's a weird question but i use a stupid method to solve it!
:-?
thank you anyway

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski »

I guess that you still have mistake in your code.
If something in global variables is initialized, it doesn't "disappear" self :))

Maybe you initialize too much elements in some loop ?

DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

zero
New poster
Posts: 5
Joined: Sat Apr 26, 2003 7:23 pm

Post by zero »

well, it is how i initialize number
strcpy(number[5][0]," - ");
where number is char number[10][5][4]

but it dose lose number[5][0][0] which should be' '
i don't know@@

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski »

Post me definiotion of your table and function , which initialize it :) I try to find your mistake :))

DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

zero
New poster
Posts: 5
Joined: Sat Apr 26, 2003 7:23 pm

Post by zero »

Dominik Michniewski wrote:Post me definiotion of your table and function , which initialize it :) I try to find your mistake :))

DM
void digitform(void)
{
strcpy(number[0][0]," - "); strcpy(number[5][0]," - ");
strcpy(number[0][1],"| | "); strcpy(number[5][1],"| ");
strcpy(number[0][2]," "); strcpy(number[5][2]," - ");
strcpy(number[0][3],"| | "); strcpy(number[5][3]," | ");
strcpy(number[0][4]," - "); strcpy(number[5][4]," - ");



return;
}

PS: funtion digitform() does like the way above from 0 to 9

int main()
{
int s;

digitform();
return 0;
}

reiners
New poster
Posts: 9
Joined: Fri May 30, 2003 6:50 pm
Location: San Francisco

706

Post by reiners »

I received WA for the program included below. Can anyone please tell me an input on which it fails, and what the expected output should be for that input?

Code: Select all

/*   @JUDGE_ID:   29339ZA   706   C++   "Getting Started"   */

#include<iostream.h>
#include <string>
#include <cmath>
using namespace std;

void display(int s, int n);
void displayHoriz(int row, int s, int digits[], int digitsLen);
void displayVert(int row, int s, int digits[], int digitsLen);

void main()
{
      int s, n;

      while (cin >> s >> n) {
		  if (s == 0 && n == 0) {
			  break;
		  }
		  display(s, n);
      }
}


const char DIGITS[10][5][3] = {{{' ', '-', ' '},  // 0
                                           {'|', ' ', '|'},
                                           {' ', ' ', ' '},
                                           {'|', ' ', '|'},
                                           {' ', '-', ' '}},
                                          {{' ', ' ', ' '},  // 1
                                           {' ', ' ', '|'},
                                           {' ', ' ', ' '},
                                           {' ', ' ', '|'},
                                           {' ', ' ', ' '}},
                                          {{' ', '-', ' '},  // 2
                                           {' ', ' ', '|'},
                                           {' ', '-', ' '},
                                           {'|', ' ', ' '},
                                           {' ', '-', ' '}},
                                          {{' ', '-', ' '},  // 3
                                           {' ', ' ', '|'},
                                           {' ', '-', ' '},
                                           {' ', ' ', '|'},
                                           {' ', '-', ' '}},
                                          {{' ', ' ', ' '},  // 4
                                           {'|', ' ', '|'},
                                           {' ', '-', ' '},
                                           {' ', ' ', '|'},
                                           {' ', ' ', ' '}},
                                          {{' ', '-', ' '},  // 5
                                           {'|', ' ', ' '},
                                           {' ', '-', ' '},
                                           {' ', ' ', '|'},
                                           {' ', '-', ' '}},
                                          {{' ', '-', ' '},  // 6
                                           {'|', ' ', ' '},
                                           {' ', '-', ' '},
                                           {'|', ' ', '|'},
                                           {' ', '-', ' '}},
                                          {{' ', '-', ' '},  // 7
                                           {' ', ' ', '|'},
                                           {' ', ' ', ' '},
                                           {' ', ' ', '|'},
                                           {' ', ' ', ' '}},
                                          {{' ', '-', ' '},  // 8
                                           {'|', ' ', '|'},
                                           {' ', '-', ' '},
                                           {'|', ' ', '|'},
                                           {' ', '-', ' '}},
                                          {{' ', '-', ' '},  // 9
                                           {'|', ' ', '|'},
                                           {' ', '-', ' '},
                                           {' ', ' ', '|'},
                                           {' ', '-', ' '}}};

void display(int s, int n) {
	int digitsLen = int(log10(n)) + 1;
    int* digits = new int[digitsLen];
    int nn = n;
	int i;
    for (i = digitsLen - 1; i >= 0; i--) {
        digits[i] = nn % 10;
        nn /= 10;
    }
    
    for (i = 0; i < 5; i++) {
        if (i % 2 == 0) {
            displayHoriz(i, s, digits, digitsLen);
        }
        else {
            displayVert(i, s, digits, digitsLen);
        }
    }
    
    cout << endl;
}

void displayHoriz(int row, int s, int digits[], int digitsLen) {
    for (int i = 0; i < digitsLen; i++) {
        int digit = digits[i];
        cout << ' ';
        for (int j = 0; j < s; j++) {
            cout << DIGITS[digit][row][1];
        }
        cout << ' ';
        if (i < digitsLen - 1) {
            cout << ' ';
        }
    }
    cout << endl;
}

void displayVert(int row, int s, int digits[], int digitsLen) {
    for (int k = 0; k < s; k++) {
        for (int i = 0; i < digitsLen; i++) {
            int digit = digits[i];
            cout << DIGITS[digit][row][0];
            for (int j = 0; j < s; j++) {
                cout << ' ';
            }
            cout << DIGITS[digit][row][2];
            if (i < digitsLen - 1) {
                cout << ' ';
            }
        }
        cout << endl;
    }
}

reiners
New poster
Posts: 9
Joined: Fri May 30, 2003 6:50 pm
Location: San Francisco

706 WA

Post by reiners »

Never mind. It's working now.

kate
New poster
Posts: 11
Joined: Thu May 22, 2003 9:37 pm

706 WA

Post by kate »

Not sure what's causing it.

Code: Select all

#include <iostream>
#include <vector>
#include <string>
using namespace std;

const int show[10][7] =
{
/*0*/	{1,1,1,1,1,1,0,},
/*1*/	{0,1,1,0,0,0,0,},
/*2*/	{1,1,0,1,1,0,1,},
/*3*/	{1,1,1,1,0,0,1,},
/*4*/	{0,1,1,0,0,1,1,},
/*5*/	{1,0,1,1,0,1,1,},
/*6*/	{1,0,1,1,1,1,1,},
/*7*/	{1,1,1,0,0,0,0,},
/*8*/	{1,1,1,1,1,1,1,},
/*9*/	{1,1,1,1,0,1,1,},
};

int main()
{
	int size;	char ch;	vector<int> num; string yes,no;
	cin >> size; 
	cin.get(ch);
	for(int i=0;i<size;i++) {
		yes+='-'; no+=' ';
	}
	cin.get(ch);
	while(ch!='\n') {
		num.push_back(int(ch)-48);
		cin.get(ch);
	}
	while(size!=0 || num.size()>1 || num[0]!=0) {
		if(size!=0) {
			// top
			for(int j=0;j<num.size();j++) {
				cout << " ";
				if(show[num[j]][0])	cout << yes;
				else cout << no;
				cout << " ";
				if(j<num.size()-1) cout << " ";				
			}
			cout << endl;
			// below top
			for(int m=0;m<size;m++) {
				for(int n=0;n<num.size();n++) {
					if(show[num[n]][5]) cout << "|";
					else cout << " ";
					cout << no;
					if(show[num[n]][1]) cout << "|";
					else cout << " ";
					if(n<num.size()-1) cout << " ";
				}
				cout << endl;
			}
			// middle
			for(int k=0;k<num.size();k++) {
				cout << " ";
				if(show[num[k]][6])	cout << yes;
				else cout << no;
				cout << " ";
				if(k<num.size()-1) cout << " ";				
			}
			cout << endl;
			// below middle
			for(int o=0;o<size;o++) {
				for(int p=0;p<num.size();p++) {
					if(show[num[p]][4]) cout << "|";
					else cout << " ";
					cout << no;
					if(show[num[p]][2]) cout << "|";
					else cout << " ";
					if(p<num.size()-1) cout << " ";
				}
				cout << endl;
			}
			// bottom
			for(int l=0;l<num.size();l++) {
				cout << " ";
				if(show[num[l]][3])	cout << yes;
				else cout << no;
				cout << " ";
				if(l<num.size()-1) cout << " ";				
			}
			cout << endl;
			num.clear(); yes=""; no="";
			cout << endl;
			cin >> size; 
			cin.get(ch);
			for(int q=0;q<size;q++) {
				yes+='-'; no+=' ';
			}
			cin.get(ch);
			while(ch!='\n') {
				num.push_back(int(ch)-48);
				cin.get(ch);
			}
		}
	}
	return 0;
}
[/code]

carneiro
Learning poster
Posts: 54
Joined: Sun May 18, 2003 1:19 am
Location: Rio de Janeiro, Brazil
Contact:

Post by carneiro »

should we concern negative numbers ?
[]s
Mauricio Oliveira Carneiro

Joseph Kurniawan
Experienced poster
Posts: 136
Joined: Tue Apr 01, 2003 6:59 am
Location: Jakarta, Indonesia

Post by Joseph Kurniawan »

Nope, there won't be any negative numbers in this problem

ileti
New poster
Posts: 5
Joined: Thu Feb 20, 2003 10:19 pm

Please help me too

Post by ileti »

In my program all numbers correct but WA is giving.I can missunderstood to line status.
e.g 4 2
// i wrote the solution here
then pass next line or wait for new input ?
In other word last input was displayed is there any new line ?

May be there is different problem.If there any advice, tell me
thanks...
from Turkiye

ileti
New poster
Posts: 5
Joined: Thu Feb 20, 2003 10:19 pm

Please help me too

Post by ileti »

In my program all numbers correct but WA is giving.I can missunderstood to line status.
e.g 4 2
// i wrote the solution here
then pass next line or wait for new input ?
In other word last input was displayed is there any new line ?

May be there is different problem.If there any advice, tell me
thanks...
from Turkiye

dhc
New poster
Posts: 1
Joined: Thu Sep 18, 2003 7:56 pm
Contact:

706 WA

Post by dhc »

#include <stdio.h>
#include <string.h>

void oito(int i,int m,int numero)
{
int j;

if (i==0)
{
printf(" ");
for (j=0;j<m;j++)
{
if (numero != 1 && numero != 4) printf("-");
else printf(" ");
}
printf(" ");
printf(" ");
}

if (i==1)
{
if (numero != 1 && numero != 2 && numero != 3 && numero != 7)
{
printf("|");
}
else
{
printf(" ");
}
for (j=0;j<m;j++)
{
printf(" ");
}
if (numero != 5 && numero != 6)
{
printf("|");
}
else
{
printf(" ");
}
printf(" ");
}

if (i==2)
{
printf(" ");
for (j=0;j<m;j++)
{
if (numero != 1 && numero != 0 && numero != 7) printf("-");
else printf(" ");
}
printf(" ");
printf(" ");
}

if (i==3)
{
if (numero == 2 || numero == 6 || numero == 8 || numero == 0)
{
printf("|");
}
else
{
printf(" ");
}
for (j=0;j<m;j++)
{
printf(" ");
}
if (numero != 2)
{
printf("|");
}
else
{
printf(" ");
}
printf(" ");
}

if (i==4)
{
printf(" ");
for (j=0;j<m;j++)
{
if (numero != 1 && numero != 4 && numero != 7) printf("-");
else printf(" ");
}
printf(" ");
printf(" ");
}
}



void main ()
{
int m,i,j,h;
char s[100];
char *f = "0";
while (scanf("%d %s",&m,&s))
{
if (m == 0 && (strcmp(f,s) == 0)) return;
h = strlen(s);

for (i=0;i<h;i++)
{
if (s>=48 && s<=57)
{
if (i==0) printf(" ");
oito(0,m,s-48);
}
}
printf("\n");

for(j=0;j<m;j++)
{
for (i=0;i<h;i++)
{
if (s>=48 && s<=57)
{
if (i==0) printf(" ");
oito(1,m,s-48);
}
}
printf("\n");
}


for (i=0;i<h;i++)
{
if (s>=48 && s<=57)
{
if (i==0) printf(" ");
oito(2,m,s-48);
}
}
printf("\n");

for (j=0;j<m;j++)
{
for (i=0;i<h;i++)
{
if (s>=48 && s[i]<=57)
{
if (i==0) printf(" ");
oito(3,m,s[i]-48);
}
}
printf("\n");
}

for (i=0;i<h;i++)
{
if (s[i]>=48 && s[i]<=57)
{
if (i==0) printf(" ");
oito(4,m,s[i]-48);
}
}
printf("\n");
}
return;
}
[c][/c]

Post Reply

Return to “Volume 7 (700-799)”