|
|||
Histogram GenerationDevelop a program that, given a collection of quiz scores, generates a histogram showing the collection’s frequency distribution. Quiz scores will be in the range zero to twenty, inclusive. Input SpecificationThe first line contains a positive integer n indicating how many collections are to be processed. Each collection is described on two or more lines, the first of which contains the number of quiz scores m (m > 0) in that collection. The remaining lines contain the quiz scores themselves, twenty scores per line up until the last one, which will have a number of scores equal to the remainder obtained when m is divided by 20. Output SpecificationFor each collection of quiz scores, the program should generate a histogram indicating the frequency with which each of the values zero through twenty occurs in that collection. The histogram’s form should be as in the sample output below. Specifically, the only quiz scores that should be mentioned explicitly in the histogram are those between the minimum and maximum scores recorded, inclusive. (For the first example below, this range is ten through nineteen.) Be sure to fill all the white space occupied by the histogram with blanks, also at the end of each line so that all of them have the same length. The number of lines generated for a histogram should be exactly k + 3, where k is the maximum number of occurrences of any of the quiz scores. This accounts for there being k asterisks in the tallest column, one line for the scale (containing dashes and plus signs), one line containing the quiz scores, and a blank line to separate one histogram from the next. Sample Input
Output for Sample Input
|
|||
University of Debrecen; Faculty of Informatics; v. 09/30/2024 |