Solved

Display

Posted on 2004-04-27
9
221 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
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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

822 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