Last Update: 12pm Wed. 3/9.
It doesn't matter; you can easily handle both kinds with the same code, as shown below.
void reverse (int *a, int length){ // ... }Such a definition will work with any array, no matter how its storage was allocated. The compiler happily converts from int [] or int *const to int*, because the pointer argument a is received by value.
(Recall: int *const means "constant pointer to int." Since the pointer is received by value, the reverse function has its own local copy of it. Changing that local copy (not done here anyway) would have no effect on the caller's copy of that pointer. Therefore, there is no reason for the compiler to force this function to keep its local pointer fixed. Therefore, the compiler lets the function receive the pointer as an int*, which works for all arrays, no matter how they're allocated.)
No, you don't.
Store the data for each bin in an object of some special type that you create yourself as a struct or class. Or, build the histogram in a 2-dimensional array. Once you have the bins stored separately in memory, determine which bin is the longest. This determines how many rows of output you'll generate.
With stream output ( cout << ), you must print rows one at a time, from top to bottom. However, assuming your bins grow from the bottom of your desired output toward the top, this means that the last element in each bin must be printed first. For each row of output, visit the bins one by one. If a given bin has enough data in it to warrant printing in the current row, then do so; otherwise, print space. Only the bottom row is guaranteed to have data in every column.