The original goal looked like a histogram plot. That does not require C++ at all. Spreadsheets (oocalc, MS Excel), plotting programs (gnuplot, Origin, SigmaPlot), statistics (R, MatLab), etc can do such plot in a heartbeat. OP wrote that he "has to use" loops and array. C++ offers std::array, std::vector and algorithms. A post on the Beginner Forum has thus two usual reasons: (1) the user wants to learn, and (2) the user does not know the alternatives. The "has to" points to the first. IMHO, focusing attention to smaller subproblems helps the learning more than handing out whole solutions.
Rows. How many rows? Probable answer is: "enough for the tallest peak". So how tall is the tallest peak? Easy, look from the static input data. However, if one does that, then one could just write out the plot as string literals (like I did in earlier comment, by hand) and it would not work if input data changes. So, do the "pop in" with algorithm.
The maximum value of an array. That is a FAQ in this Forum. I would use std::max_element (its reference documentation has an example on how to), but a for loop can be used to achieve the same. Your pick.
Condition We want an expression that yields true or false appropriately. Relational operator?
Tallest peak == Rows, and should produce true on every row.
0 == peak should produce false on every row.
How about:
1 2 3
|
Rows relop (down + peak)
// where relop is one of
// != < <= == >= >
|
Considering what we want to see, <= looks to be close enough.
Rows <= (down + peak)
Are we explicit enough now?
[Edit] Oh my: Another poster has a curiously similar homework:
http://www2.cs.uh.edu/~acl/cs1410/Assignment/prog6.pdf