?
Solved

Display

Posted on 2004-04-27
9
Medium Priority
?
227 Views
Last Modified: 2012-05-04
write a program that displays numbers in an LC-display-like style on the computer.
Input  
The input file contains several lines, one for each number to be displayed. Each line contains two integers s, n (  1<=s<=10, 0<=n<=999999 ), where n is the number to be displayed and s is the size in which it shall be displayed.
The input file will be terminated by a line containing two zeros. This line should not be processed.
Output  
Output the numbers given in the input file in an LC-display-style using s ``-'' signs for the horizontal segments and s ``|'' signs for the vertical ones. Each digit occupies exactly s+2 columns and 2s+3 rows. (Be sure to fill all the white space occupied by the digits with blanks, also for the last digit.) There has to be exactly one column of blanks between two digits.
Output a blank line after each number. (You will find a sample of each digit in the sample output.)





Sample Input  
2 12345
3 67890
0 0
Sample Output  
      --   --        --
   |    |    | |  | |  
   |    |    | |  | |  
      --   --   --   --
   | |       |    |    |
   | |       |    |    |
      --   --        --

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

0
Comment
Question by:krithi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 3

Expert Comment

by:CoolBreeze
ID: 10934339
Sorry, krithi, it is against the charter of this site for you to ask this type question, and it is also against the rules for any experts to help you.
Please re-read the membership agreement:
http://www.experts-exchange.com/jsp/memberAgreement.jsp
Pay particlular attention to this section:
perhaps it would be more helpful if you state what your problem is.

0
 

Author Comment

by:krithi
ID: 10934373
i don need any code dude all i wan is little bit help or psuedocode
0
 
LVL 3

Accepted Solution

by:
CoolBreeze earned 252 total points
ID: 10934427
oops, that was a mispost. but nevertheless, as I said it would be more helpful if you state what your problem is. Without stating what the problem is, it sounds more like a homework question.

regarding the problem, a easy way out is to initialize a 2D array, with each element representing the real display. if the element contains 0, draw a space, contains 1 draw a '-', contains 2 draw a '|'. that is the simple way out though not the only way out.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:krithi
ID: 10936080
Can anyone give me more details.

thnx
krithi
0
 
LVL 40

Assisted Solution

by:Kyle Abrahams
Kyle Abrahams earned 249 total points
ID: 10936496


CoolBreeze's 2D array is the way to go.


Basically have a static array of how many digits you need.  

Then have a function for each number:

IE:

Draw_one

Draw_two


and mark everything in the array.

Then you just need to output the array.

0
 
LVL 4

Assisted Solution

by:skypalae
skypalae earned 249 total points
ID: 10937411
Hi guys,
this doesn't look like HW to me .. more it looks like ACM programming contest :)

anyway .. the algorithm you can use 2dim array simulating the dot matrix display (as ged pointed) or you can use some more sophisticated algorithm.

// you get this line, don't you? it's just your digital representation of number 0 (followed by number 1 etc.)
char *n0[9] = {" --- ", "|   |", "|   |", "|   |", "     ", "|   |", "|   |", "|   |", " --- "} ;
char *n1[9] .....
....

// this is just array of all numbers
char *n[][] = {n0, n1, n2, n3, n4 ...... n9} ;

// now display every line of segment display:
for (i=0; i<9; i++)
    // and in every line treat all numbers
    for (j=0; j<strlen(numberstring); j++)
        // and here just display correct line of correct number
        printf ("%s", n[numberstring[j]][i]) ;
    printf ("\n") ;


----------------------------------------------

i just read your post correctly and found out the size parameter .. ok, there are 2 solutions. or you predefine the strings for all sizes, or you use some algorithm for the string creation in runtime. Following algorithm can be used

// top segment, top side segments, middle segment, bottom side segments, bottom segment
char *n0[] = {" - ", "| |", "   ", "| |", " - "} ;

1st line:
print 1st char of top (" ")
#s print 2nd char
print 3rd char

topside lines:
print 1st char of topside
#s print 2nd char
print 3rd char

middle:
...
etc, etc

Cheers! S.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question