Hi!
I have to write program, who print Triangle made with numbers from 1 to 9,like this:
1
21
321
4321
54321
654321
7654321
87654321
987654321
I wrote code:
#include <iostream.h>
#include <stdlib.h>
int main()
{
int first, last;
cout << endl;
for (first = 1 ; first <= 9 ; first++)
{
cout << " ";
for (last = 1 ; last <= first; last++)
{
cout <<last;
}
cout<< endl;
}
cout << endl << endl << endl;
system("PAUSE");
return 0;
}
which put on the screen Triangle in form:
1
12
123
1234
12345
123456
1234567
12345678
123456789
I think, that I need to use if statment to invert numbers, but i dont know how. Any ideas?