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

Post Reply
Sherman MXF
New poster
Posts: 14
Joined: Sun May 26, 2002 1:54 pm
Location: China

706 - LCD Display

Post by Sherman MXF » Tue Jun 25, 2002 8:42 am

Can someone tell me where is wrong with my output?
[pascal]
program acm706;
type
coltype=array[1..30]of boolean;
const
t:array['0'..'9',1..3,1..3]of byte=(((1,1,0),(1,0,1),(1,1,0)),
((0,0,0),(0,0,0),(1,1,0)),
((0,1,0),(1,1,1),(1,0,0)),
((0,0,0),(1,1,1),(1,1,0)),
((1,0,0),(0,1,0),(1,1,0)),
((1,0,0),(1,1,1),(0,1,0)),
((1,1,0),(1,1,1),(0,1,0)),
((0,0,0),(1,0,0),(1,1,0)),
((1,1,0),(1,1,1),(1,1,0)),
((1,0,0),(1,1,1),(1,1,0)));
var
scr:array[1..30]of string;
size:byte;
s:string;
h:byte;


procedure readdata;
var
p:byte;
l:longint;
begin
readln(size,l);
str(l,s);
h:=size*2+3;
end;

procedure buildscreen;
var
l:byte;
col:coltype;

procedure convert(d:char;n:byte;var c:coltype);
var
i,j:byte;
begin
fillchar(c,sizeof(c),0);
case n of
1,3:begin
for i:=1 to 2 do
if t[d,n,i]=1 then
begin
for j:=(i-1)*(size+1)+2 to (i-1)*(size+1)+size+1 do
c[j]:=true;
end;
end;
2:begin
for i:=1 to 3 do
if t[d,n,i]=1 then c[(i-1)*(size+1)+1]:=true;
end;
end;
end;

procedure outcol(n:byte;c:coltype);
var
i,j:byte;
begin
case n of
1,3:begin
for i:=1 to h do
begin
if c then scr:=scr+'|' else scr:=scr+' ';
end;
end;
2:begin
for j:=1 to size do
begin
for i:=1 to h do
begin
if c then scr:=scr+'-' else scr:=scr+' ';
end;
end;
end;
end;
end;

procedure outdigit(d:char);
var
i:byte;
begin
for i:=1 to 3 do
begin
convert(d,i,col);
outcol(i,col);
end;
end;

begin
for l:=1 to 20 do
scr[l]:='';
for l:=1 to length(s) do
begin
outdigit(s[l]);
fillchar(col,sizeof(col),0);
outcol(1,col);
end;
end;

procedure out;
var
i:byte;
begin
for i:=1 to h do
begin
writeln(scr[i]);
end;
writeln;
end;

procedure run;
begin
repeat
readdata;
if size<>0 then
begin
buildscreen;
out;
end;
until size=0;
end;

begin
run;
end.
[/pascal]
Thanks.

xenon
Learning poster
Posts: 100
Joined: Fri May 24, 2002 10:35 am
Location: Scheveningen, Holland

Post by xenon » Tue Jun 25, 2002 8:58 am

The problem description says:
There has to be exactly one column of blanks between two digits.

Sherman MXF
New poster
Posts: 14
Joined: Sun May 26, 2002 1:54 pm
Location: China

Post by Sherman MXF » Tue Jun 25, 2002 8:59 am

Sorry, i found my array "scr" is too small...

Melon Melon
New poster
Posts: 17
Joined: Fri May 31, 2002 6:30 pm
Contact:

help....

Post by Melon Melon » Sat Jul 06, 2002 12:02 pm

i get WA for this Qs..
i wonder what is the meaning of
Be sure to fill all the white space occupied by the digits with blanks, also for the last digit.
where the "last digit"... is it needed special manipulation on it??
i just treate it as usual digits..can i?????

10153EN
Experienced poster
Posts: 148
Joined: Sun Jan 06, 2002 2:00 am
Location: Hong Kong
Contact:

Post by 10153EN » Sat Jul 06, 2002 12:14 pm

This is to fill all the white space occupied by the digits with blanks, also for the last digit:


[c]
bbbbbb--bbb--bbbbbbbb--b
bbb|bbbb|bbbb|b|bb|b|bbb
bbb|bbbb|bbbb|b|bb|b|bbb
bbbbbb--bbb--bbb--bbb--b
bbb|b|bbbbbbb|bbbb|bbbb|
bbb|b|bbbbbbb|bbbb|bbbb|
bbbbbb--bbb--bbbbbbbb--b
[/c]

This is to fill all the white space occupied by the digits with blanks, but not the last digit:

[c]
bbbbbb--bbb--bbbbbbbb--
bbb|bbbb|bbbb|b|bb|b|
bbb|bbbb|bbbb|b|bb|b|
bbbbbb--bbb--bbb--bbb--
bbb|b|bbbbbbb|bbbb|bbbb|
bbb|b|bbbbbbb|bbbb|bbbb|
bbbbbb--bbb--bbbbbbbb--
[/c]

where b is the blanks.

Hope can help~ :D

xenon
Learning poster
Posts: 100
Joined: Fri May 24, 2002 10:35 am
Location: Scheveningen, Holland

Post by xenon » Sat Jul 06, 2002 12:22 pm

In the last digit also fill then 'unused space' at the end of the line with blanks:

Code: Select all

bbbn
bb|n
bbbn
bb|n
bbbn

b-bn
bb|n
b-bn
|bbn
b-bn

etc.
not:

n
bb|n
n
bb|n
n

b-n
bb|n
b-n
|n
b-n
here 'b' is a blank, 'n' is the end of line.

xenon
Learning poster
Posts: 100
Joined: Fri May 24, 2002 10:35 am
Location: Scheveningen, Holland

Post by xenon » Sat Jul 06, 2002 12:26 pm

10153EN:
We were writing replies simultaniously :D

10153EN
Experienced poster
Posts: 148
Joined: Sun Jan 06, 2002 2:00 am
Location: Hong Kong
Contact:

Post by 10153EN » Sat Jul 06, 2002 12:32 pm

Haha... yes, and the idea of both messages are the same~ :D :D

Melon Melon
New poster
Posts: 17
Joined: Fri May 31, 2002 6:30 pm
Contact:

Post by Melon Melon » Sat Jul 06, 2002 1:23 pm

ths both.. :D
...
i ve dealt with last digit..
but i dont know why still got WA.... :(
...
here is my code...where get bugs???

[c]
#include <stdio.h>
#include <string.h>

/* global variables */
int no[10][7] = {{1, 1, 1, 0, 1, 1, 1},
{0, 0, 1, 0, 0, 1, 0},
{1, 0, 1, 1, 1 ,0, 1},
{1, 0, 1, 1, 0, 1, 1},
{0, 1, 1, 1, 0, 1, 0},
{1, 1, 0, 1, 0, 1, 1},
{1, 1, 0, 1, 1, 1, 1},
{1, 0, 1, 0, 0, 1, 0},
{1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 0, 1, 1}};
int len, s;

/* print "-" */
void row(char n[], int pos)
{
int j, k, digit;

for(j = 0; j < len; j++)
{
digit = n[j] - '0';

printf(" ");
if(no[digit][pos])
for(k = 0; k < s; k++)
printf("-");
else
for(k = 0; k < s; k++)
printf(" ");
printf(" ");

if(j != (len - 1))
printf(" ");
}
printf("\n");
}

/* print "|" */
void col(char n[], int pos1, int pos2)
{
int i, j, k, digit;

for(i = 0; i < s; i++)
{
for(j = 0; j < len; j++)
{
digit = n[j] - '0';

if(no[digit][pos1])
printf("|");
else
printf(" ");

for(k = 0; k < s; k++)
printf(" ");

if(no[digit][pos2])
printf("|");
else
printf(" ");

if(j != len - 1)
printf(" ");
}
printf("\n");
}
}


int main(int argv, char *argc[])
{
char n[100];

while(scanf("%d %s", &s, n) && s && (n[0] != '0'))
{
len = strlen(n);

row(n, 0);
col(n, 1, 2);
row(n, 3);
col(n, 4, 5);
row(n, 6);

putchar('\n');

}

return 0;
}
[/c]

Picard
Learning poster
Posts: 96
Joined: Mon Jun 24, 2002 1:22 pm
Location: Hungary
Contact:

Post by Picard » Sat Jul 06, 2002 1:54 pm

1 0
2 0
3 0
...

are all valid input pairs

Melon Melon
New poster
Posts: 17
Joined: Fri May 31, 2002 6:30 pm
Contact:

Post by Melon Melon » Sat Jul 06, 2002 2:17 pm

oic...
ths a lot!!!
^___^

doha200
New poster
Posts: 1
Joined: Tue Oct 08, 2002 10:33 pm

Post by doha200 » Tue Oct 08, 2002 10:39 pm

[/cpp]
#include "iostream"
#include "string"

using namespace std;


bool A (char n)
{
if( n == '1' || n == '4')
return 0;
else
return 1;
}

bool B (char n)
{
if( n == '5' || n == '6')
return 0;
else
return 1;
}

bool C (char n)
{
if( n == '1' || n == '7' || n == '0')
return 0;
else
return 1;
}

bool D (char n)
{
if( n == '2')
return 0;
else
return 1;
}


bool E (char n)
{
if( n == '1' || n == '4' || n == '7')
return 0;
else
return 1;
}

bool F (char n)
{
if( n == '0' || n == '2' || n == '6' || n == '8')
return 1;
else
return 0;
}

bool G (char n)
{
if( n == '1' || n == '2' || n == '3' || n == '7')
return 0;
else
return 1;
}

void DisplayLCD (int size,string data)
{
int i,j,n;
int nRows,nCols;
nRows = 3 + 2*size;
nCols = 2 + size;
int h = -1;
bool RState = 0 , CState = 0;

for(i =0;i<nRows;i++)
{
for(n =0;n<data.size ();n++)
{
if(i%(nRows/2) == 0)
{
cout<<' ';
if(!i) h=i;
switch(h){
case 0:
RState = A(data[n]);
break;
case 1:
RState = C (data[n]);
break;
case 2:
RState = E (data[n]);
break;
}
for(j = 0;j<size;j++)
{
if(RState) cout<<'-';
else cout<<' ';
}
cout<<' ';
}
else
{
for(j =0;j<nCols;j++)
{
if(!h)
{
if(j == 0) CState = G (data[n]);
if(j == nCols-1) CState = B (data[n]);
}
else
{
if(j == 0) CState = F (data[n]);
if(j == nCols-1) CState = D (data[n]);
}
if(CState) cout<<'|';
else cout<<' ';
CState = 0;
}
}
cout<<'\t';
}
cout<<endl;
if(size != 1)
if(i%size == 0 && i > 0) h++;
if(size == 1)
if((i+1)%2 == 0) h++;
}
}


void main()
{
string data;
char line[80];

int size;
cin >> size;
while(size)
{
cin >> line;
data = line;
DisplayLCD (size,data);
cout<<endl;
cin >> size;
}
}

[/list]

evanmars
New poster
Posts: 4
Joined: Mon Mar 10, 2003 10:13 pm

706 WA

Post by evanmars » Mon Mar 17, 2003 5:36 pm

Seems to work for me. What case doesn't it work for?

// @JUDGE_ID: ******* 706 C++

#include <iostream.h>
#include <string.h>

int main()
{
int size, numlen;
char number[256];
char numerals[10][5][3] =
{{{' ','-',' '},{'|',' ','|'},
{' ',' ',' '},{'|',' ','|'},{' ','-',' '}},
{{' ',' ',' '},{' ',' ','|'},
{' ',' ',' '},{' ',' ','|'},{' ',' ',' '}},
{{' ','-',' '},{' ',' ','|'},
{' ','-',' '},{'|',' ',' '},{' ','-',' '}},
{{' ','-',' '},{' ',' ','|'},
{' ','-',' '},{' ',' ','|'},{' ','-',' '}},
{{' ',' ',' '},{'|',' ','|'},
{' ','-',' '},{' ',' ','|'},{' ',' ',' '}},
{{' ','-',' '},{'|',' ',' '},
{' ','-',' '},{' ',' ','|'},{' ','-',' '}},
{{' ','-',' '},{'|',' ',' '},
{' ','-',' '},{'|',' ','|'},{' ','-',' '}},
{{' ','-',' '},{' ',' ','|'},
{' ',' ',' '},{' ',' ','|'},{' ',' ',' '}},
{{' ','-',' '},{'|',' ','|'},
{' ','-',' '},{'|',' ','|'},{' ','-',' '}},
{{' ','-',' '},{'|',' ','|'},
{' ','-',' '},{' ',' ','|'},{' ',' ',' '}}};

while(1)
{
cin >> size >> number;

numlen = strlen(number);

if(size == 0 && strchr(number,'0') != NULL)
break;

if(size != 0)
{
for(int i = 0; i < 5; i++)
{
for(int j = 0; j < numlen; j++)
{
cout << numerals[number[j]-48][0];
for(int k = 0; k < size; k++)
cout << numerals[number[j]-48][1];
cout << numerals[number[j]-48][2];
cout<< ' ';
}
cout << endl;

if(i%2)
{
for(int l = 0; l < size - 1; l++)
{
for(int m = 0; m < numlen; m++)
{
cout << numerals[number[m]-48][0];
for(int n = 0; n < size; n++)
cout << numerals[number[m]-48][1];
cout << numerals[number[m]-48][2];
cout << ' ';
}
cout << endl;
}
}
}
}
}

return 0;
}

Pasq
New poster
Posts: 5
Joined: Mon Jun 24, 2002 5:53 pm

706 LCD - WA

Post by Pasq » Wed Mar 19, 2003 10:41 pm

Can you help me, why I got WA ?
[pascal]
program dupa;
var
wie :longint;
jakie :string;
i,j :longint;
n :longint;
puste,pelne :string;
begin
readln(wie,jakie);
while wie>0 do
begin
pelne:='';
puste:='';
n:=length(jakie);
for i:=1 to wie do
begin
puste:=puste+' ';
pelne:=pelne+'-';
end;
for i:=2 to n do
begin
write(' ');
case jakie of
'1':write(puste);
'4':write(puste);
else write(pelne);
end;
write(' ');
if i<>n then write(' ');
end;
writeln;
for j:=1 to wie do
begin
for i:=2 to n do
begin
case jakie of
'4':write('|');
'5':write('|');
'6':write('|');
'8':write('|');
'9':write('|');
'0':write('|');
else write(' ');
end;
write(puste);
case jakie of
'1':write('|');
'2':write('|');
'3':write('|');
'4':write('|');
'7':write('|');
'8':write('|');
'9':write('|');
'0':write('|');
else write(' ');
end;
if i<>n then write(' ');
end;
writeln;
end;
for i:=2 to n do
begin
write(' ');
case jakie of
'1':write(puste);
'7':write(puste);
'0':write(puste);
else write(pelne);
end;
write(' ');
if i<>n then write(' ');
end;
writeln;
for j:=1 to wie do
begin
for i:=2 to n do
begin
case jakie of
'2':write('|');
'6':write('|');
'8':write('|');
'0':write('|');
else write(' ');
end;
write(puste);
case jakie of
'1':write('|');
'3':write('|');
'4':write('|');
'5':write('|');
'6':write('|');
'7':write('|');
'8':write('|');
'9':write('|');
'0':write('|');
else write(' ');
end;
if i<>n then write(' ');
end;
writeln;
end;
for i:=2 to n do
begin
write(' ');
case jakie of
'1':write(puste);
'4':write(puste);
'7':write(puste);
else write(pelne);
end;
write(' ');
if i<>n then write(' ');
end;
writeln;
readln(wie,jakie);
if wie<>0
then
writeln;
end;
end.
[/pascal]
or give me an example where my program gives WA.

Eric
Learning poster
Posts: 83
Joined: Wed Sep 11, 2002 6:28 pm
Location: Hong Kong

Post by Eric » Sat Apr 12, 2003 2:14 pm

Would you use the [C++][/C++] code to format your program well in order to let other people read your program more easily?
Otherwise, other people can hardly help you.

Post Reply

Return to “Volume 7 (700-799)”