### Help: Pyramid Nested Loop Pattern is inverted

The output that I need is this:
----------------------------------------------------
 ``123456`` ``````Enter Preferred Number: (any number from 0-9)(ex. 5) 1 1_2 1_2_3 1_2_3_4 1_2_3_4_5``````

...and so on...

----------------------------------------------------
 ``123456`` ``````Enter Preferred Number: (any number from 0-9)(ex. 5) 5_ 4_5_ 3_4_5_ 2_3_4_5_ 1_2_3_4_5_``````

...and so on...

How can I reverse the numbering and remove the underscore after the side of the pyramid, to match the example above? I don't know what the problem is. Please help me...

By the way, the program that I am using is Turbo C++...even though obsolete, but I still keep using it...XD

Here is the code that I made for the second example:
 ``123456789101112131415161718192021222324`` ``````#include "conio.h" #include "iostream.h" int main() { textcolor(LIGHTGREEN); clrscr(); int i,j,num; cout<<"Enter Preferred Number: "; cin>>num; clrscr(); for (i=1;i<=num;i++) { for (j=num;j>i;j--) cout<<" "; for (int k=num-i+1;k<=num;k++) { cout<
 ``12345678910111213141516171819202122232425262728`` ``````#include "conio.h" #include "iostream.h" int main() { textcolor(LIGHTGREEN); clrscr(); int i,j,num; cout<<"Enter Preferred Number: "; cin>>num; clrscr(); for (i=1;i<=num;i++) { for (j=num;j>i;j--) cout<<" "; for (int k=1; k<=i;k++) { cout<

Just modified a bit, what do you say?
Last edited on
Just for fun:
 ``12345678910111213141516171819202122232425262728`` ``````#include using namespace std; int main() { int num = 0; int curr = 0; cout<<"Enter Preferred Number: "; cin >> num; do { int med = (num - curr); for (int i = 1; i < med; ++i) { cout << " "; } for (int i = 0; i < curr; ++i) { cout << i + 1 << "_"; } cout << ++curr << endl; } while (curr < num); return 0; }``````
thanks for the help guys....really appreciated it! =)
Topic archived. No new replies allowed.