Not a biggie. You just did one of the loop conditions wrong.
1 2 3 4 5 6 7 8 9 10 11
for (int i=0; i<=10; i++){
for(int j=0; j<i; j++){ // You had this as greater than before, which
cout << "*"; // would have skipped over this loop every time
}
for(int j=i; j<10; j++)
{
cout << " ";
}
cout << endl;
}
You don't really need the spaces. It looks the same even if you don't print them. I would just erase that last for loop.
I did wrong the triangles.
The direction was opposite for that.
I changed the above triangle.
Also finally I heard of my teacher.
The triangle needs three variables as below.
for (int j = 10; j > 0; j--) {
for(int i = 1; i < j; i++) {
cout << ' ';
}
for(int n = 10; n >= j; n--) {
cout << '*';
}
cout << endl;
It was a good lesson for increasing my knowledge in my empty head!
Thanks!
yoshi
P.S. Sorry again. the above triangle couldn't fix for differet direction which I want to!