Hello.
I have a question regarding a task I was given.
It goes : Fill the array with random numbers and then print out how many times theyve appeared like so :
/*
ARRAY : 0 0 0 0 1 1 1 2 2 2 2 2 6 6 6 6 6 6 4 4 5 5 5
OUTPUT :
^
^ |
^ | |
| ^ | | ^
| | | | ^ |
| | | | | |
---------------------
4 3 5 6 2 3
0 1 2 3 4 5
*/
So Ive decided to use a char 2D array for the graphical part, and one additional 1D array where Ive stored the number of occurences of each element. The problem is that I dont know how to format that 2D array so that it could resemble that picture. My 2D array looks like this
/*
ARRAY : 0 0 0 0 1 1 1 2 2 2 2 2 6 6 6 6 6 6 4 4 5 5 5
OUTPUT :
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
---------------------
4 3 5 6 2 3
0 1 2 3 4 5
*/
I have found a max number in the occurences array which in this example is six, so there are six rows. I would be grateful if someone could help me with the logic of this problem, or how could I place those damn little '^' caps where they should be. Thank you very much for any given aid!!