<strong><span style="font-size:14px;">#include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
for(int i=1;i<=2*n+1;i++)
cout<<n<<" ";
cout<<endl;
for(int j=1;j<n;j++)
{
cout<<n<<" ";
for(int h=1;h<=j;h++)
cout<<(n-h)<<" ";
for(int i=1;i<=2*n-(2*j+1);i++)
cout<<(n-j)<<" ";
for(int h=j;h>0;h--)
cout<<(n-h)<<" ";
cout<<n<<endl;
}
for(int j=n;j>=1;j--)
{
cout<<n<<" ";
for(int h=1;h<=j;h++)
cout<<(n-h)<<" ";
for(int i=1;i<=2*n-(2*j);i++)
cout<<(n-j)<<" ";
for(int h=j-1;h>0;h--)
cout<<(n-h)<<" ";
cout<<n<<endl;
}
for(int i=1;i<=2*n+1;i++)
cout<<n<<" ";
cout<<endl;
for(int i=1;i<=6*n+1;i++)
cout<<"-";
cout<<endl;
in
c++回形方阵基本算法
最新推荐文章于 2024-08-29 08:52:45 发布