### reverse triangle problem

hi, have this reverse triangle that i cannot completely solve, hope to get some help. here's my code

 ``12345678910111213141516171819202122232425262728`` ``````#include #include using namespace std; int main() { int x; //declare the variable int i = 1,j = 1; //declare the variables cout<< "Enter a positive odd number: "; //ask user to input how many lines cin>>x; for (int i=1;i<=x;i++) { for(int j=1; j<=i-1;j++) { cout<<" "; } for (int j=1; j<=(x-(2*i-2));j++) { cout<

say, i put in 13,this will produce,
 ``` 1234567890123 12345678901 123456789 1234567 12345 123 1 ```

while my teacher demand output like this,
 ``` 3210987654321 21098765432 109876543 0987654 98765 876 7 ```

my demand it has to be positive and odd number, i still have not made that limitation yet, right now I am focusing on trying produce the desire outcome, therefore I only try positive odd number first.

I also do not know how to fix the excessive spacing at the end. if i omit the "cout<<endl;" it will produce everything in one line, however if i put it in the code, the result is just like that.

thanks for the help guys
Last edited on
Change:
`for (int j=1; j<=(x-(2*i-2));j++)`
to
`for (int j=(x-(2*i-2)); j>=1;j--)`
that's only gonna reverse the number, however still not resulting the same results as what my professor demand.