Making my bar graph appear vertically

Hello, I am having a little trouble figuring out how to make my output (the "*'s") appear as a vertical graph. So as an example, if I were to input my numbers like this: 1 2 3 4 0, this is what it shows up as * * * ** ***** and the program would end once it hit 0. I would like the desired output to look something like this if I entered: 1 2 3 4 3 2 1 10 0
*
*
*
*
*
*
* *
*** *
***** *
********
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  #include <iostream>
#include <limits>
using namespace std;

int main()
{
    const int MAX = 100;
    int values[MAX];
    int input_number;
    int total_number = 0;
    int largest_number = 0;

    for (int i = 0; i < MAX; i++)
    {
        cin >> input_number;
        if (input_number != 0)
        {
                total_number++;
                values[i] = input_number;
        }

    else if (input_number == 0)
    {
        for(int t = 0;t<total_number;t++)
        {
            if(values[t]>largest_number)
            largest_number = values[t];
        }

    for (int j = 0; j <largest_number; ++j)
    {
        for (int i = 0; i <total_number; ++i)
        cout << (j+values[i] >= largest_number ? '*' : ' ');
    }
    break;
    }
    }

    return 0;
}


Any tips or suggestions would be appreciated. Thanks!
Last edited on
Topic archived. No new replies allowed.