c++写一个沙漏形状的星号图怎么实现呢
第三个图怎么用c++实现呢? 本帖最后由 BngThea 于 2017-10-13 10:34 编辑int arr[] ={3,2,1,2,3};
for (int i = 0;i < sizeof(arr)/sizeof(int); i++)
{
for (int j = arr; j > 0; j--)
{
int c = 3 - j;
while (c--)
cout << " ";
cout << "* ";
}
cout << endl;
}
当然,还有一种更为简单粗暴的做法,直接输出:
strings[] = {
"* * *",
" * * ",
"*",
" * * ",
"* * *",
};
for (int k = 0; k < s->length(); k++)
cout << s<<endl;
页:
[1]