这玩意儿是红题?
像这种烂题倒不如打表:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
if(n==1){
cout<<" 1";
}
if(n==2){
cout<<" 1 2"<<endl;
cout<<" 4 3"<<endl;
}
if(n==3){
cout<<" 1 2 3"<<endl;
cout<<" 8 9 4"<<endl;
cout<<" 7 6 5"<<endl;
}
if(n==4){
cout<<" 1 2 3 4"<<endl;
cout<<" 12 13 14 5"<<endl;
cout<<" 11 16 15 6"<<endl;
cout<<" 10 9 8 7"<<endl;
}
if(n==5){
cout<<" 1 2 3 4 5"<<endl;
cout<<" 16 17 18 19 6"<<endl;
cout<<" 15 24 25 20 7"<<endl;
cout<<" 14 23 22 21 8"<<endl;
cout<<" 13 12 11 10 9"<<endl;
}
if(n==6){
cout<<" 1 2 3 4 5 6"<<endl;
cout<<" 20 21 22 23 24 7"<<endl;
cout<<" 19 32 33 34 25 8"<<endl;
cout<<" 18 31 36 35 26 9"<<endl;
cout<<" 17 30 29 28 27 10"<<endl;
cout<<" 16 15 14 13 12 11"<<endl;
}
if(n==7){
cout<<" 1 2 3 4 5 6 7"<<endl;
cout<<" 24 25 26 27 28 29 8"<<endl;
cout<<" 23 40 41 42 43 30 9"<<endl;
cout<<" 22 39 48 49 44 31 10"<<endl;
cout<<" 21 38 47 46 45 32 11"<<endl;
cout<<" 20 37 36 35 34 33 12"<<endl;
cout<<" 19 18 17 16 15 14 13"<<endl;
}
if(n==8)