Writing out the histogram should be easy now. You don't need to store the words since the rest of the program only needs their length. In freq, store the number of words/lines of length 1, in freq those of length 2, etc., and in freq those of length >10. The data structure you need is an array used as frequency table: int freq Then, as often, the central data structure is the key to solving the problem. Histogram refers to the visual presentation used for summarizing the discrete or the continuous data and the example of which includes the visual presentation on the graph, the complaints of the customer made in the bank on the different parameters where the most reported reason of the complaint will have the highest height in the graph presented. Here's how to "eat up" lines that are too long. I suggest you simplify the problem by solving it for the case of one word per line, so you can use fgets. This tip should get you started! If you need further help, comment below. So you should think your program as having two parts (and you'll make this kind of division in practically every program you write): first, a part that will make calculations and then a part that will output them in a certain format (the histogram). If we establish that it can't be done, then there's no choice but to know all the values of the histogram beforehand. I loved the pseudo-code! Some good thinking there, but you're still not ordering your program right.Īs you said yourself, you can't read the text, go back and print an X in a particular row.
0 Comments
Leave a Reply. |