你题目的解答代码如下:
#include<iostream>
using namespace std;
int main()
{
int x,y,nrows=6;
for (y = 1; y <= nrows; y++)
{
for (x = 1; x <= nrows-y; x++)
cout << "#";
for (x = 1; x <= y*2-1; x++)
if (x%2==1)
cout << "*";
else
cout << "#";
for (x = 1; x <= nrows-y; x++)
cout << "#";
cout << endl;
}
return 0;
}
如有帮助,望采纳!谢谢!