K
K
Kirill2016-07-29 22:46:54
C++ / C#
Kirill, 2016-07-29 22:46:54

How to build a histogram?

Given a file containing source code in the C programming language. Construct a histogram of the use of loops (while , for , do .. while) in this program.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
#
#algooptimize #bottize, 2016-07-29
@Marshall_nsk

Leave asterisks or spaces.

R
Roman Mirilaczvili, 2016-07-30
@2ord

Find the maximum and minimum values, calculate the relative values ​​as a percentage, display each rectangle by multiplying the screen height of the rectangle taken as 100% by the percentage.
If in the console, then you can display the character "\u2592" or asterisks, filling the height of each rectangle with them. A histogram can be drawn horizontally or vertically.

A
abcd0x00, 2016-07-30
@abcd0x00

This is a difficult task for a beginner.
1. First you need to make a lexical analyzer that separates the text into tokens. Also, loops can be nested - a token within a token.
2. Here, and then, when you have a stream of tokens, you can count the corresponding tokens - get an array of quantities.
3. When you have an array of quantities, you can pass it to the histogram builder.
Building a histogram is the easiest part of this whole task.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question