Trouble with nested repetition
Hi im working on a program that is meant to output numbers like:
1
12
123
1234
12345
, now i can do that, however, i can't quite figure out how to out put the numbers in this fashion:
5
45
345
2345
12345
this is my current code:
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 41 42 43 44 45 46 47 48 49 50 51
|
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//Simpler version, does the same thing
for ( int i = 1; i <= 5; i ++ )
{
for ( int j = 1; j <= i; j ++ )
{
cout << j;
}
cout << endl;
}
cout << endl << endl;
for ( int i = 1; i <= 5; i ++ )
{
for ( int j = 1; j <= 5; j ++ )
{
cout << j;
}
cout << endl;
}
cout << endl << endl;
cout << endl << endl;
system("pause");
return 1;
}
|
any advice would be appreciated
Topic archived. No new replies allowed.