套方块
我想开学了,emmmmmmm……
#include<bits/stdc++.h>
using namespace std;
int main()
{
int w;
cin>>w;
char a[w][w];
for(int i=0;i<w/2;i++)
{
if(i%2==0)
{
for(int j=i;j<w-i;j++)
{
a[j][i]=’’;
a[j][w-i-1]=’’;
a[i][j]=’’;
a[w-i-1][j]=’’;
}
}
else
{
for(int j=i;j<w-i;j++)
{
a[j][i]=’ ‘;
a[j][w-i-1]=’ ‘;
a[i][j]=’ ‘;
a[w-i-1][j]=’ ';
}
}
}
for(int i=0;i<w;i++)
{
for(int j=0;j<w;j++)
cout<<a[i][j];
cout<<endl;
}
}