Solved

Display

Posted on 2004-04-27
9
220 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
convert char array to number in c 5 83
best sources to up-to-date in C++? 8 71
How to convert MFC APP to Win32 APP. 19 69
computer science syllabus 3 70
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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…
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.

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now