I tried to create an hourglass with asterisk characters using 'for' loop... both decrement and increment works fine, but I got stucked with text alignment where those asterisks supposed to be printed in the center and justified to bring an hourglass look instead of being sticked to left or right of the screen...
any clue to get alignment works with loop result?
thx in advance and sorry for my bad English...
here's the code I made so far:
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
int bintang,baris;
for(bintang=4; bintang>0; bintang--)
{
for(baris=0; baris<bintang; baris++) {
cout.width(2);
cout << "*";
}
cout << "\n";
if (baris==1){
for(bintang=0; bintang<3; bintang++)
{
for(baris=-2; baris<bintang; baris++)
{
cout.width(2);
cout << "*";
}
cout << "\n";
}
break;
}
}
cout << "\n";
system("pause");
}