#include <iostream>
usingnamespace std;
int main()
{
int column = 10;
int row = 10;
int line = 0;
int star = 0;
int space = 0;
do
{
do
{
cout << " ";
space++;
}
while (space < line);
do {
cout << "*";
star++;
}
while (star < column);
cout << endl;
} while (line++ < row);
system("pause");
return 0;
}
#include <iostream>
usingnamespace std;
int main()
{
int column = 10;
int row = 10;
int line = 0;
int star = 0;
int space = 0;
do
{
space = -1;
do
{
cout << "&";
space++;
} while (space < line);
star = space;
do {
cout << "*";
star++;
} while (star < column+1);
cout << endl;
} while (line++ < row);
system("pause");
return 0;
}
Maybe what you posted is what you want, but if the first line has 10 stars, the next line should have 8 or it's not going to look centered. So my first question is, do you want the stars to line up on the right, or centered down the middle ?
#include <iostream>
usingnamespace std;
int main()
{
int column = 10;
int row = 10;
int line = 0;
int star = 10;
int space = 0;
do
{
do
{
cout << " ";
} while (space++ < line);
space=line/2;
do
{
cout << "*";
} while (star-- > 0 );
star=row-line-1;
cout << endl;
} while (line++ < row);
return 0;
}
The do while does always at least one iteration. If you print the leading space with do while for each row, then every row will have at least one space.
Use the 'output' tags to format text in your post to get verbatim, fixed-width characters.