Page 5 of 15

Posted: Sat Aug 07, 2004 5:09 pm
by little joey
No, you don't wrap long lines; the maximum line length (for an eight digit number) is 8*12+7=103 characters.
Your output looks good, apart from the wrapping.
Are you sure you fill up every line to it's full length, also for 5 and 6 as the last digit?
Are you sure you don't print an extra column of spaces at the end the last digit?
Are you sure you print an empty line (that's without spaces) after each number (including the last)?

That's about everything that can go wrong... your characters look fine.

Posted: Sat Aug 07, 2004 5:10 pm
by bellidoks
Thank you very much for your help. I'll try to solve the problem and see what the server says...

Posted: Sun Aug 08, 2004 3:03 am
by gmenhorn
little joey wrote:No, you don't wrap long lines; the maximum line length (for an eight digit number) is 8*12+7=103 characters.
Your output looks good, apart from the wrapping.
Are you sure you fill up every line to it's full length, also for 5 and 6 as the last digit?
Are you sure you don't print an extra column of spaces at the end the last digit?
Are you sure you print an empty line (that's without spaces) after each number (including the last)?

That's about everything that can go wrong... your characters look fine.
Hi joey, thanks for the fast response! To answer your questions:
- took out wrapping
- I'm sure that every line is filled to its full length
- I don't print an extra column of spaces at the end of the last digit
- I print an empty line, without spaces, after each number including the last

I replaced the spaces with period characters to make it clearer how my output looks. The same input from the my previous post was used and wrapping removed. Here are the results. There must be some case that I'm missing but I can't for the life of me figure out what it is. I've read over the description thousands of times trying find what that subtle issue is. Again, thanks for taking a look.

Code: Select all

......--...--........--.
...|....|....|.|..|.|...
...|....|....|.|..|.|...
......--...--...--...--.
...|.|.......|....|....|
...|.|.......|....|....|
......--...--........--.

.---...---...---...---...---.
|.........|.|...|.|...|.|...|
|.........|.|...|.|...|.|...|
|.........|.|...|.|...|.|...|
.---.........---...---.......
|...|.....|.|...|.....|.|...|
|...|.....|.|...|.....|.|...|
|...|.....|.|...|.....|.|...|
.---.........---...---...---.

.----------...----------...----------...----------...----------...----------...----------...----------.
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|.|..........|
.----------...----------...----------...----------...----------...----------...----------...----------.
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
...........|............|............|............|............|............|............|............|
.----------...----------...----------...----------...----------...----------...----------...----------.

.----------.
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
............
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
|..........|
.----------.

.........-----...-----.........
......|.|.....|.|.....|.|.....|
......|.|.....|.|.....|.|.....|
......|.|.....|.|.....|.|.....|
......|.|.....|.|.....|.|.....|
......|.|.....|.|.....|.|.....|
.................-----...-----.
......|.|.....|.......|.......|
......|.|.....|.......|.......|
......|.|.....|.......|.......|
......|.|.....|.......|.......|
......|.|.....|.......|.......|
.........-----...-----.........

..................................
.....|......|......|......|......|
.....|......|......|......|......|
.....|......|......|......|......|
.....|......|......|......|......|
..................................
.....|......|......|......|......|
.....|......|......|......|......|
.....|......|......|......|......|
.....|......|......|......|......|
..................................

.......---...---.........---...---.........---.
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
.......---...---.........---...---.........---.
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
....|.|...|.|...|.....|.|...|.|...|.....|.|...|
.......---...---.........---...---.........---.

.-.
|.|
...
|.|
.-.

.--.
|..|
|..|
....
|..|
|..|
.--.

.---.
|...|
|...|
|...|
.....
|...|
|...|
|...|
.---.

.--------....................................--------.
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.........|..........|.|........|..........|.|.........
.--------..............--------..............--------.
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.........|..........|..........|..........|..........|
.--------....................................--------.


Posted: Sun Aug 08, 2004 9:29 am
by little joey
Beats me. Your output looks good.
You can PM me your code, if you like, and I will have a look at it.

Posted: Sun Aug 08, 2004 9:14 pm
by ..
How about leading zero?
Your test input doesn't have one input with leading zero.

I am not sure if the input has leading zero, but my code also handled that

Posted: Sun Aug 08, 2004 10:31 pm
by little joey
My AC program doesn't handle leading zeros (the answer for 007 is the same as for 7, namely one zeven), so I think there are no leading zeros in the input... Good idea, though.

Posted: Mon Aug 09, 2004 4:29 am
by gmenhorn
I just rewrote the problem from scratch, submitted, and got an 'Accepted'! The only think that I can think of that is different (don't have access to the old version at the moment) is that I used loops this time rather than use std::string's resize function to create the strings. Maybe, there is some implementation difference in the compiler (I compiled/tested using g++ 3.3.1) or it didn't handle some strange case that I didn't have a test case for. Thanks for your time though.

--
George

Posted: Mon Aug 16, 2004 1:05 pm
by bellidoks
I got AC now :D

Posted: Sat Sep 18, 2004 6:24 pm
by itsme86
I've got the same problem as the original poster. The only weird thing I can see in my output is if you try printing a number with 0 size:

Code: Select all

$ ./706 < temp.txt
......--...--........--.
...|....|....|.|..|.|...
...|....|....|.|..|.|...
......--...--...--...--.
...|.|.......|....|....|
...|.|.......|....|....|
......--...--........--.

.---...---...---...---...---.
|.........|.|...|.|...|.|...|
|.........|.|...|.|...|.|...|
|.........|.|...|.|...|.|...|
.---.........---...---.......
|...|.....|.|...|.....|.|...|
|...|.....|.|...|.....|.|...|
|...|.....|.|...|.....|.|...|
.---.........---...---...---.

$
But then...

Code: Select all

1 8
.-.
|.|
.-.
|.|
.-.

0 8
..
..
..

Will someone that's gotten AC on this problem tell me what kind of output they get for size 0 numbers? Or anyone have any other ideas as to what might be wrong?

Thanks in advance!

EDIT: Here's my code if it provides a clue (with .'s instead of spaces):

Code: Select all

#include <stdio.h>
#include <stdlib.h>

#define TOP         0x1
#define TOPLEFT     0x2
#define TOPRIGHT    0x4
#define CENTER      0x8
#define BOTTOMLEFT  0x10
#define BOTTOMRIGHT 0x20
#define BOTTOM      0x40

unsigned char bitmaps[10] =
{
  TOP | TOPLEFT | TOPRIGHT | BOTTOMLEFT | BOTTOMRIGHT | BOTTOM,
  TOPRIGHT | BOTTOMRIGHT,
  TOP | TOPRIGHT | CENTER | BOTTOMLEFT | BOTTOM,
  TOP | TOPRIGHT | CENTER | BOTTOMRIGHT | BOTTOM,
  TOPLEFT | TOPRIGHT | CENTER | BOTTOMRIGHT,
  TOP | TOPLEFT | CENTER | BOTTOMRIGHT | BOTTOM,
  TOP | TOPLEFT | CENTER | BOTTOMLEFT | BOTTOMRIGHT | BOTTOM,
  TOP | TOPRIGHT | BOTTOMRIGHT,
  TOP | TOPLEFT | TOPRIGHT | CENTER | BOTTOMLEFT | BOTTOMRIGHT | BOTTOM,
  TOP | TOPLEFT | TOPRIGHT | CENTER | BOTTOMRIGHT | BOTTOM
};

void print_horizontal(int num, int size, int bit)
{
  int i, ch;

  putchar('.');
  ch = bitmaps[num] & bit?'-':'.';
  for(i = 0;i < size;++i)
    putchar(ch);
  putchar('.');
}

void print_vertical(int num, int size, int leftbit, int rightbit)
{
  int i;

  putchar(bitmaps[num] & leftbit?'|':'.');
  for(i = 0;i < size;++i)
    putchar('.');
  putchar(bitmaps[num] & rightbit?'|':'.');
}

int main(void)
{
  char buf[50], *p, *q;
  int i, size;

  while(fgets(buf, sizeof(buf), stdin))
  {
    size = atoi(buf);
    for(p = buf;*p && *p != ' ';p++);
    while(*p == ' ')
      p++;
    if(!size && *p == '0')
      break;

    for(q = p;*q >= '0' && *q <= '9';++q)
    {
      if(q-p)
        putchar('.');
      print_horizontal(*q-'0', size, TOP);
    }
    putchar('\n');
    for(i = 0;i < size;++i)
    {
      for(q = p;*q >= '0' && *q <= '9';++q)
      {
        if(q-p)
          putchar('.');
        print_vertical(*q-'0', size, TOPLEFT, TOPRIGHT);
      }
      putchar('\n');
    }
    for(q = p;*q >= '0' && *q <= '9';++q)
    {
      if(q-p)
        putchar('.');
      print_horizontal(*q-'0', size, CENTER);
    }
    putchar('\n');
    for(i = 0;i < size;++i)
    {
      for(q = p;*q >= '0' && *q <= '9';++q)
      {
        if(q-p)
          putchar('.');
        print_vertical(*q-'0', size, BOTTOMLEFT, BOTTOMRIGHT);
      }
      putchar('\n');
    }
    for(q = p;*q >= '0' && *q <= '9';++q)
    {
      if(q-p)
        putchar('.');
      print_horizontal(*q-'0', size, BOTTOM);
    }

    puts("\n");
  }

  return 0;
}

Posted: Sat Sep 18, 2004 7:02 pm
by alu_mathics

Code: Select all

1 8
0 8
8 0
4 007
0 1234
0 0

Code: Select all

 -  
| | 
 -  
| | 
 -  

   
   
   

 --------  
|        | 
|        | 
|        | 
|        | 
|        | 
|        | 
|        | 
|        | 
           
|        | 
|        | 
|        | 
|        | 
|        | 
|        | 
|        | 
|        | 
 --------  

 ----   ----   ----  
|    | |    |      | 
|    | |    |      | 
|    | |    |      | 
|    | |    |      | 
                     
|    | |    |      | 
|    | |    |      | 
|    | |    |      | 
|    | |    |      | 
 ----   ----         

            
            
            

Posted: Fri Oct 01, 2004 10:56 pm
by randomtaiwanese
this is my code... but it doesnt seem to work :( keep getting wrong answers


[java]import java.io.IOException;
import java.util.StringTokenizer;
class Main
{
int[][] lcd;
int count=1;
int[] num;
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;
int m, n;
lcd = new int[11][3];
while ((input = Main.ReadLn (255)) != null)
{
tokenizer=new StringTokenizer (input);
m=Integer.parseInt(tokenizer.nextToken());
n=Integer.parseInt(tokenizer.nextToken());
if(!(m==0))
{
lcd[count][1]=m;
lcd[count][2]=n;
count++;
}
else if(m==0)
{
printLCD();
}
}
}
void Act1(int length, int size)
{
for(int j=0;j<length;j++)
{
switch(num[j])
{
case 1:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print(" ");
break;
case 2:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 3:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 4:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print(" ");
break;
case 5:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 6:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 7:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 8:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 9:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 0:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;

}
System.out.print(" ");
}
}
void Act2(int length,int size)
{
for(int u=0;u<size;u++)
{
System.out.println("");
for(int j=0;j<length;j++)
{
switch(num[j])
{
case 1:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;
case 2:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;
case 3:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;
case 4:
System.out.print("|");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;
case 5:
System.out.print("|");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print(" ");
break;
case 6:
System.out.print("|");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print(" ");
break;
case 7:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;
case 8:
System.out.print("|");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;
case 9:
System.out.print("|");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;
case 0:
System.out.print("|");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;

}
System.out.print(" ");
}
}
}
void Act3(int length, int size)
{
for(int j=0;j<length;j++)
{
switch(num[j])
{
case 1:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print(" ");
break;
case 2:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 3:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 4:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 5:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 6:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 7:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print(" ");
break;
case 8:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 9:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 0:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print(" ");
break;

}
System.out.print(" ");
}
}
void Act4(int length,int size)
{
for(int u=0;u<size;u++)
{
System.out.println("");
for(int j=0;j<length;j++)
{
switch(num[j])
{
case 1:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;
case 2:
System.out.print("|");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print(" ");
break;
case 3:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;
case 4:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;
case 5:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;
case 6:
System.out.print("|");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;
case 7:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;
case 8:
System.out.print("|");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;
case 9:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;
case 0:
System.out.print("|");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print("|");
break;

}
System.out.print(" ");
}
}
}
void Act5(int length, int size)
{
for(int j=0;j<length;j++)
{
switch(num[j])
{
case 1:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print(" ");
break;
case 2:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 3:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 4:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print(" ");
break;
case 5:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 6:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 7:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print(" ");
}
System.out.print(" ");
break;
case 8:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 9:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;
case 0:
System.out.print(" ");
for(int l=0;l<size;l++)
{
System.out.print("-");
}
System.out.print(" ");
break;

}
System.out.print(" ");
}
}
void printLCD()
{
for(int i=1;i<count;i++)
{
if(!(i==1))
{
System.out.println("");
}
int size = lcd[1];
String str = new Integer(lcd[2]).toString();
int length = str.length();
num = new int[length];
for(int j=0;j<length;j++)
{
num[j] = Integer.parseInt(new Character(str.charAt(j)).toString());
}
Act1(length, size);
Act2(length, size);
System.out.println("");
Act3(length, size);
Act4(length, size);
System.out.println("");
Act5(length, size);
if(i==1)
{
System.out.println("");
}
}
}
}
[/java]

Posted: Sat Oct 02, 2004 7:26 pm
by hiloshi
hi randomtaiwanese.

I think you don't need to use such many function, sould use the Display Number template instead.
Try to draw some Display Number by hands.

For example, when the Number is 3 and Size is 1, it is represented by follow.

Code: Select all

.-.
..|
.-.
..|
.-.
"." represents a space.
Then you should think the Number 3 in Size=2.
How you draw 3?
Where would be change, and where would be not change?
Think about it, then your souce will get more simple and you will find a bug.

Posted: Thu Oct 07, 2004 8:04 pm
by randomtaiwanese
can someone give me some good sample test inputs???

706.... o.O

Posted: Thu Oct 14, 2004 8:14 pm
by randomtaiwanese
this is my code, and it doesnt work, according to the judge...
[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)&&(size>0))&&((Integer.parseInt(lcd[2])<99999999)))
{
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();
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();
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();
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();
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();
drawBlank();
}
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 need help please

Posted: Mon Oct 18, 2004 10:57 pm
by randomtaiwanese
[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();
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();
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();
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();
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();
drawBlank();
}
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]
this is my code