I have a program where the user enters some numbers, and those numbers are outputted again, along with (input number) number of # signs on each line. I have the output, but I need some help for the rest.
For example, input 1 2 3 should be this:
Code:
Number of values to graph: 3
1 2 3
1 | #
2 | ##
3 | ###
but instead it's:
Code:
Number of values to graph: 3
1
2
3
1
2
3
How do I get from the second one to the top one?
My code is:
Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main( ) {
int numbers[10];
int howmany;
cout << "Number of values to graph: ";
cin >> howmany;
for( int i = 0; i < howmany; i++ )
{
cin >> numbers[i];
}
if( howmany <= 0 )
cout << "No numbers entered." << endl;
else
{
cout << numbers[0];
for( int x = 1; x < howmany; x++ )
cout << setw(2) << endl << numbers[x];
cout << endl;
}
}