706 - LCD Display
Moderator: Board moderators
-
- New poster
- Posts: 32
- Joined: Fri Oct 01, 2004 10:53 pm
-
- New poster
- Posts: 32
- Joined: Fri Oct 01, 2004 10:53 pm
this is new code, fixed the problems u have mentioned, but still WAafonsocsc wrote:Hi,
I did a diff with your output and mine and here's the result:
Your program is printing one extra blank line in the beginning, and is adding one extra space at the end of each line.
Hope it helps

[java]
import java.io.IOException;
import java.util.StringTokenizer;
class Main
{
String[][] lcd;
int count=1;
int[] num;
int size, length;
char[] chars = new char[3];
final char space = ' ';
static String ReadLn(int maxLg)
{
byte lin[]=new byte[maxLg];
int lg=0,car=-1;
String line="";
try
{
while(lg<maxLg)
{
car=System.in.read();
if ((car<0)||(car=='\n'))
{
break;
}
lin[lg++]+=car;
}
}
catch(IOException e)
{
return(null);
}
if ((car<0)&&(lg==0))
{
return(null);
}
return (new String (lin, 0, lg));
}
public static void main(String[] args)
{
Main newMain = new Main();
newMain.start();
}
void start()
{
String input;
StringTokenizer tokenizer;
String m, n;
lcd = new String[11][3];
while ((input = Main.ReadLn (65535)) != null)
{
tokenizer=new StringTokenizer (input);
m=tokenizer.nextToken();
n=tokenizer.nextToken();
if((Integer.parseInt(m)==0)&&(Integer.parseInt(n)==0))
{
//here start drawing
for(int i=1;i<count;i++)
{
//System.out.println("");
size = Integer.parseInt(lcd[1]);
if(size>10)
break;
String str = lcd[2];
length = str.length();
num = new int[length];
for(int j=0;j<length;j++)
{
num[j] = Integer.parseInt(new Character(str.charAt(j)).toString());
}
//draw first line
setChar(0,0);
setChar(2,0);
for(int j=0;j<length;j++)
{
if((num[j]==1)||(num[j]==4))
setChar(1,0);
else
setChar(1,2);
draw();
if(j!=length-1)
drawBlank();
}
//second line
setChar(1,0);
for(int u=0;u<size;u++)
{
System.out.println("");
for(int j=0;j<length;j++)
{
if((num[j]==1)||(num[j]==2)||(num[j]==3)||(num[j]==7))
setChar(0,0);
else
setChar(0,1);
if((num[j]==5)||(num[j]==6))
setChar(2,0);
else
setChar(2,1);
draw();
if(j!=length-1)
drawBlank();
}
}
System.out.println("");
//third line
setChar(0,0);
setChar(2,0);
for(int j=0;j<length;j++)
{
if((num[j]==1)||(num[j]==7)||(num[j]==0))
setChar(1,0);
else
setChar(1,2);
draw();
if(j!=length-1)
drawBlank();
}
//forth line
setChar(1,0);
for(int u=0;u<size;u++)
{
System.out.println("");
for(int j=0;j<length;j++)
{
if(num[j]==2)
setChar(2,0);
else
setChar(2,1);
if((num[j]==2)||(num[j]==6)||(num[j]==8)||(num[j]==0))
setChar(0,1);
else
setChar(0,0);
draw();
if(j!=length-1)
drawBlank();
}
}
System.out.println("");
//fifth line
setChar(0,0);
setChar(2,0);
for(int j=0;j<length;j++)
{
if((num[j]==1)||(num[j]==4)||(num[j]==7))
setChar(1,0);
else
setChar(1,2);
draw();
if(j!=length-1)
drawBlank();
}
if(i!=count-1)
{
System.out.println("");
System.out.println("");
}
}
System.out.println("");
break;
}
else
{
lcd[count][1]=m;
lcd[count][2]=n;
count++;
}
}
}
void drawBlank()
{
System.out.print(space);
}
void setChar(int charnum, int chartype)
{
switch(chartype)
{
case 0:
chars[charnum]=space;
break;
case 1:
chars[charnum]='|';
break;
case 2:
chars[charnum]='-';
break;
}
}
void draw()
{
System.out.print(chars[0]);
for(int l=0;l<size;l++)
{
System.out.print(chars[1]);
}
System.out.print(chars[2]);
}
}[/java]
706: can't understand why WA, can someone help me?
hello everyone
I'm having great troubles with this nasty, tricky problem; I think I have the right answers, but the judge doesn't seem to agree with me
my ouputs for:
2 12345
3 67890
10 99999999
10 0
5 1094
4 11111
3 18818818
1 0
2 0
3 0
8 31415
2 007
0 0
are:
if you prefer, by replacing the blanks with dots (".") I get this output:
is there any wrong output?
is there something missing?
I would be very glad if a good soul would help me because I've been stuck with this problem for a long time
I'm having great troubles with this nasty, tricky problem; I think I have the right answers, but the judge doesn't seem to agree with me

my ouputs for:
2 12345
3 67890
10 99999999
10 0
5 1094
4 11111
3 18818818
1 0
2 0
3 0
8 31415
2 007
0 0
are:
Code: Select all
----------
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
----------
----- -----
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
----- -----
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
----- -----
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
--- --- --- --- ---
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
--- --- --- --- ---
| | | | | | | | | | | | |
| | | | | | | | | | | | |
| | | | | | | | | | | | |
--- --- --- --- ---
-
| |
| |
-
--
| |
| |
| |
| |
--
---
| |
| |
| |
| |
| |
| |
---
-------- --------
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
-------- -------- --------
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
-------- --------
-- -- --
| | | | |
| | | | |
| | | | |
| | | | |
-- --
Code: Select all
......--...--........--.
...|....|....|.|..|.|...
...|....|....|.|..|.|...
......--...--...--...--.
...|.|.......|....|....|
...|.|.......|....|....|
......--...--........--.
.---...---...---...---...---.
|.........|.|...|.|...|.|...|
|.........|.|...|.|...|.|...|
|.........|.|...|.|...|.|...|
.---.........---...---.......
|...|.....|.|...|.....|.|...|
|...|.....|.|...|.....|.|...|
|...|.....|.|...|.....|.|...|
.---.........---...---...---.
.----------...----------...----------...----------...----------...----------...----------...----------.
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
.----------...----------...----------...----------...----------...----------...----------...----------.
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
.----------...----------...----------...----------...----------...----------...----------...----------.
.----------.
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
............
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
.----------.
.........-----...-----.........
......|.|.....|.|.....|.|.....|
......|.|.....|.|.....|.|.....|
......|.|.....|.|.....|.|.....|
......|.|.....|.|.....|.|.....|
......|.|.....|.|.....|.|.....|
.................-----...-----.
......|.|.....|.......|.......|
......|.|.....|.......|.......|
......|.|.....|.......|.......|
......|.|.....|.......|.......|
......|.|.....|.......|.......|
.........-----...-----.........
..................................
.....|......|......|......|......|
.....|......|......|......|......|
.....|......|......|......|......|
.....|......|......|......|......|
..................................
.....|......|......|......|......|
.....|......|......|......|......|
.....|......|......|......|......|
.....|......|......|......|......|
..................................
.......---...---.........---...---.........---.
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
.......---...---.........---...---.........---.
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
.......---...---.........---...---.........---.
.-.
|.|
...
|.|
.-.
.--.
|..|
|..|
....
|..|
|..|
.--.
.---.
|...|
|...|
|...|
.....
|...|
|...|
|...|
.---.
.--------....................................--------.
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.--------..............--------..............--------.
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.--------....................................--------.
.--...--...--.
|..|.|..|....|
|..|.|..|....|
..............
|..|.|..|....|
|..|.|..|....|
.--...--......
is there something missing?
I would be very glad if a good soul would help me because I've been stuck with this problem for a long time
-
- New poster
- Posts: 28
- Joined: Mon Nov 15, 2004 5:00 pm
706 LC-Display Presentation Error
I know a PE doesn't mean much to many people but it does to me. I'm stumped as to how to make my output perfect. Here is my code. Please help. Thanks in advance!
[c]#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int factor, digits[8], last, temp, ii, jj, zz;
char toprint, t[2];
char code[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 }
};
t[1] = '\0';
while (scanf("%d ", &factor) != EOF)
{
if (!factor)
break;
last = 0;
while ((toprint = (char)getc(stdin)) != '\n' && toprint != EOF)
{
t[0] = toprint;
digits[last++] = atoi(t);
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][0]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf("\n");
for (ii = 0; ii < factor; ii++)
{
for (jj = 0; jj < last; jj++)
{
toprint = (code[digits[jj]][1]) ? '|' : ' ';
printf("%c", toprint);
for (zz = 0; zz < factor; zz++)
printf(" ");
toprint = (code[digits[jj]][2]) ? '|' : ' ';
printf("%c", toprint);
if (jj != last - 1)
printf(" ");
}
printf("\n");
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][3]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf("\n");
for (ii = 0; ii < factor; ii++)
{
for (jj = 0; jj < last; jj++)
{
toprint = (code[digits[jj]][4]) ? '|' : ' ';
printf("%c", toprint);
for (zz = 0; zz < factor; zz++)
printf(" ");
toprint = (code[digits[jj]][5]) ? '|' : ' ';
printf("%c", toprint);
if (jj != last - 1)
printf(" ");
}
printf("\n");
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][6]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf("\n\n");
}
return 0;
}
[/c]
[c]#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int factor, digits[8], last, temp, ii, jj, zz;
char toprint, t[2];
char code[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 }
};
t[1] = '\0';
while (scanf("%d ", &factor) != EOF)
{
if (!factor)
break;
last = 0;
while ((toprint = (char)getc(stdin)) != '\n' && toprint != EOF)
{
t[0] = toprint;
digits[last++] = atoi(t);
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][0]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf("\n");
for (ii = 0; ii < factor; ii++)
{
for (jj = 0; jj < last; jj++)
{
toprint = (code[digits[jj]][1]) ? '|' : ' ';
printf("%c", toprint);
for (zz = 0; zz < factor; zz++)
printf(" ");
toprint = (code[digits[jj]][2]) ? '|' : ' ';
printf("%c", toprint);
if (jj != last - 1)
printf(" ");
}
printf("\n");
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][3]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf("\n");
for (ii = 0; ii < factor; ii++)
{
for (jj = 0; jj < last; jj++)
{
toprint = (code[digits[jj]][4]) ? '|' : ' ';
printf("%c", toprint);
for (zz = 0; zz < factor; zz++)
printf(" ");
toprint = (code[digits[jj]][5]) ? '|' : ' ';
printf("%c", toprint);
if (jj != last - 1)
printf(" ");
}
printf("\n");
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][6]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf("\n\n");
}
return 0;
}
[/c]
-
- Experienced poster
- Posts: 183
- Joined: Thu Nov 11, 2004 12:35 pm
- Location: AIUB, Bangladesh
Hi try this out
here '*' means space

here '*' means space

Code: Select all
your output:
3 0
*---
|***|
|***|
|***|
****
|***|
|***|
|***|
*---
my output:
3 0
*---*
|***|
|***|
|***|
*****
|***|
|***|
|***|
*---*
check out the last asteriks, u cant just keep it empty , u have to fill the whole size with space or either '|' or '-'
i hope u will pass PE this time......and u know how to modify ur code....
Goodluck :wink:
Jalal : AIUB SPARKS
-
- New poster
- Posts: 28
- Joined: Mon Nov 15, 2004 5:00 pm
Doesn't work
Hmm did what you said, but it still didn't work.
Here's my modified code:
[c]#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int factor, digits[8], last, temp, ii, jj, zz;
char toprint, t[2];
char code[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 }
};
t[1] = '\0';
while (scanf("%d ", &factor) != EOF)
{
if (!factor)
break;
last = 0;
while ((toprint = (char)getc(stdin)) != '\n' && toprint != EOF)
{
t[0] = toprint;
digits[last++] = atoi(t);
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][0]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf(" ");
printf("\n");
for (ii = 0; ii < factor; ii++)
{
for (jj = 0; jj < last; jj++)
{
toprint = (code[digits[jj]][1]) ? '|' : ' ';
printf("%c", toprint);
for (zz = 0; zz < factor; zz++)
printf(" ");
toprint = (code[digits[jj]][2]) ? '|' : ' ';
printf("%c", toprint);
if (jj != last - 1)
printf(" ");
}
printf("\n");
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][3]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf(" ");
printf("\n");
for (ii = 0; ii < factor; ii++)
{
for (jj = 0; jj < last; jj++)
{
toprint = (code[digits[jj]][4]) ? '|' : ' ';
printf("%c", toprint);
for (zz = 0; zz < factor; zz++)
printf(" ");
toprint = (code[digits[jj]][5]) ? '|' : ' ';
printf("%c", toprint);
if (jj != last - 1)
printf(" ");
}
printf("\n");
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][6]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf(" ");
printf("\n\n");
}
return 0;
}
[/c]

Here's my modified code:
[c]#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int factor, digits[8], last, temp, ii, jj, zz;
char toprint, t[2];
char code[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 }
};
t[1] = '\0';
while (scanf("%d ", &factor) != EOF)
{
if (!factor)
break;
last = 0;
while ((toprint = (char)getc(stdin)) != '\n' && toprint != EOF)
{
t[0] = toprint;
digits[last++] = atoi(t);
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][0]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf(" ");
printf("\n");
for (ii = 0; ii < factor; ii++)
{
for (jj = 0; jj < last; jj++)
{
toprint = (code[digits[jj]][1]) ? '|' : ' ';
printf("%c", toprint);
for (zz = 0; zz < factor; zz++)
printf(" ");
toprint = (code[digits[jj]][2]) ? '|' : ' ';
printf("%c", toprint);
if (jj != last - 1)
printf(" ");
}
printf("\n");
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][3]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf(" ");
printf("\n");
for (ii = 0; ii < factor; ii++)
{
for (jj = 0; jj < last; jj++)
{
toprint = (code[digits[jj]][4]) ? '|' : ' ';
printf("%c", toprint);
for (zz = 0; zz < factor; zz++)
printf(" ");
toprint = (code[digits[jj]][5]) ? '|' : ' ';
printf("%c", toprint);
if (jj != last - 1)
printf(" ");
}
printf("\n");
}
for (ii = 0; ii < last; ii++)
{
toprint = (code[digits[ii]][6]) ? '-' : ' ';
printf(" ");
for (jj = 0; jj < factor; jj++)
printf("%c", toprint);
if (ii != last - 1)
printf(" ");
}
printf(" ");
printf("\n\n");
}
return 0;
}
[/c]
-
- New poster
- Posts: 28
- Joined: Mon Nov 15, 2004 5:00 pm
-
- Experienced poster
- Posts: 183
- Joined: Thu Nov 11, 2004 12:35 pm
- Location: AIUB, Bangladesh
Well happy to hear that ur problem is solved....
I did not tried it in programming challenges judge.....but if the problem descriction is same then it should have worked......
but u can try one thing there......cut out newline after the last output. now question is how u will undestand which one is last input?.....
well there is a way, u can print newline before each output except the 1st one and thats not so hard, actually I solved it in this way at the 1st time and this judge gave me PE......then i print newline after each case and got Acc, so there is a possibility that the opposite happens in programming challenges judge.......but dont try anything else, because i dont think that will work
well, goodbye and goodluck.......
I did not tried it in programming challenges judge.....but if the problem descriction is same then it should have worked......
but u can try one thing there......cut out newline after the last output. now question is how u will undestand which one is last input?.....
well there is a way, u can print newline before each output except the 1st one and thats not so hard, actually I solved it in this way at the 1st time and this judge gave me PE......then i print newline after each case and got Acc, so there is a possibility that the opposite happens in programming challenges judge.......but dont try anything else, because i dont think that will work

Jalal : AIUB SPARKS
-
- New poster
- Posts: 28
- Joined: Mon Nov 15, 2004 5:00 pm
-
- New poster
- Posts: 10
- Joined: Mon Mar 28, 2005 5:59 pm
- Location: Dhaka, Bangladesh
- Contact:
706
Could you please help me with my code? The judge answered "WRONG ANSWER". I don't understand why.
Is there any special input present, what my code didn't consider?
I didn't consider NEGATIVE numbers
I didn't consider SIZE = 0
I didn't consider LEADING ZEROs.
This is my code
Is there any special input present, what my code didn't consider?
I didn't consider NEGATIVE numbers
I didn't consider SIZE = 0
I didn't consider LEADING ZEROs.
This is my code
Code: Select all
//Wrong answer
#include<stdio.h>
#include<math.h>
char a[10][5][3]=
{
//ZERO
' ','-',' ',
'|',' ','|',
' ',' ',' ',
'|',' ','|',
' ','-',' ',
//ONE
' ',' ',' ',
' ',' ','|',
' ',' ',' ',
' ',' ','|',
' ',' ',' ',
//TWO
' ','-',' ',
' ',' ','|',
' ','-',' ',
'|',' ',' ',
' ','-',' ',
//THREE
' ','-',' ',
' ',' ','|',
' ','-',' ',
' ',' ','|',
' ','-',' ',
//FOUR
' ',' ',' ',
'|',' ','|',
' ','-',' ',
' ',' ','|',
' ',' ',' ',
//FIVE
' ','-',' ',
'|',' ',' ',
' ','-',' ',
' ',' ','|',
' ','-',' ',
//SIX
' ','-',' ',
'|',' ',' ',
' ','-',' ',
'|',' ','|',
' ','-',' ',
//SEVEN
' ','-',' ',
' ',' ','|',
' ',' ',' ',
' ',' ','|',
' ',' ',' ',
//EIGHT
' ','-',' ',
'|',' ','|',
' ','-',' ',
'|',' ','|',
' ','-',' ',
//NINE
' ','-',' ',
'|',' ','|',
' ','-',' ',
' ',' ','|',
' ','-',' ',
};
int main()
{
// freopen("706.in","r",stdin);
// freopen("706.txt","w",stdout);
int s, n;
int backup,digitCount,i,j;
int process;
int power;
int k,l,x;
int Count=0;
int flag=0;
int flag2=0;
int linef=0;
while( (scanf("%d%d",&s,&n)==2)&&(s||n))
{
if(flag2)
printf("\n");
flag2=1;
backup = n;
digitCount = (int)floor(log10(n))+1;
for(i=0; i<5; )
{
flag=0;
for(j=digitCount-1; j>=0; j--)
{
if(flag)
printf(" ");
flag=1;
power = (int)pow(10,j);
process = n/power;
n = n%power;
int minus=0;
int line=0;
for(x=0; x<3; x++)
{
if(a[process][i][x]=='-')
{
minus=1;
break;
}
if(a[process][i][x]=='|')
{
line=1;
break;
}
}
if(minus)
{
minus=0;
for(k=0; k<3; k++)
{
if(a[process][i][k]=='-'||(a[process][i][k]==' '&&k==1))
{
for(l=0; l<s; l++)
{
printf("%c",a[process][i][k]);
}
}
else
{
printf("%c",a[process][i][k]);
}
}
}
else if(line)
{
linef =1;
if(Count<s)
{
line=0;
for(k=0; k<3; k++)
{
if(a[process][i][k]=='|')
{
printf("%c",a[process][i][k]);
}
else
{
if(a[process][i][k]==' '&&k==1)
{
for(l=0; l<s; l++)
{
printf("%c",a[process][i][k]);
}
}
else
{
printf("%c",a[process][i][k]);
}
}
}
}
}
else
{
for(k=0; k<3; k++)
{
if(a[process][i][k]==' '&&k==1)
{
for(l=0; l<s; l++)
{
printf("%c",a[process][i][k]);
}
}
else
{
printf("%c",a[process][i][k]);
}
}
}
if(Count==s)Count=0;
}
printf("\n");
if(linef)
{
Count++;
linef=0;
}
n = backup;
if(Count==s)Count=0;
if(Count==0){i++;}
}
}
return 0;
}
Programmer? No, no, i am a speedy typist.
-
- Experienced poster
- Posts: 106
- Joined: Thu Jan 29, 2004 12:07 pm
- Location: Bangladesh
- Contact: