题解 | #X形图案#
X形图案
http://www.nowcoder.com/practice/83d6afe3018e44539c51265165806ee4
#include<iostream>
using namespace std;
int main()
{
int a;
while(cin>>a)
{
for(int i=1;i<=a;i++)
{
for(int j=1;j<=a;j++)
{
if(i==j)
cout<<'*';
else if(j==a-i+1)
cout<<'*';
else
cout<<' ';
}
cout<<endl;
}
}
return 0;
}
```在打印这种复杂图形时可以用两个for循环,并将这两个循环想象成一个直角坐标系,再用几个条件语句去画图形