Solved

Display

Posted on 2004-04-27
9
225 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 84 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 83 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 83 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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

617 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