大侠,过来帮忙!
#include <iostream> //这是改好的using namespace std;
int main()
{
cout<<"请输入一个数"<<endl;
int m;
cin>>m;
int x=0; int y=m-1;
int count=0;
int i,j; int a[21][21]; int n=1;
while (count<=m*m)
{ for (i=x,j=x;j<=y;j++)
{ a[i][j]=n; cout<<a[i][j]; count++; n++; }
for ( i=x+1,j=y;i<=y;i++)
{ a[i][j]=n; cout<<a[i][j]; count++; n++; }
for (i=y,j=y-1;j>=x;j--)
{ a[i][j]=n; cout<<a[i][j]; count++; n++; }
for (j=x,i=y-1;i>=x+1;i--)
{ a[i][j]=n; cout<<a[i][j]; count++; n++; }
x++; y--; }
return 0;
}