DWITE Online Computer Programming Contest

ASCII bar graphs

March 2010
Problem 1

The input file DATA1.txt will contain 5 lines, integers −5 ≤ N ≤ 5.

The output file OUT1.txt will plot the numbers as a graph. Each whole number gets an asterisk *. When the number is negative, the asterisks are placed left of the central line drawn with a pipe |; a positive number has asterisks on the right. Zero has no asterisks drawn. Empty spaces are filled with the hyphen - for alignment. See the sample graphs as examples.

Sample Input:
Sample Output: