跪求大佬挑错!!
WA代码:
#include<iostream>
using namespace std;
int main() {
int n,p[10][10],x=0,f=1,h=0,l=0;
cin>>n;
double m=4;
for(int i=1;i<=2*n-1;i++,f++,m-=0.5) {
for(double j=1;j<=m;j++) {
if(f%4==1) {l++;x++;p[h][l]=x;}
if(f%4==2) {h++;x++;p[h][l]=x;}
if(f%4==3) {l--;x++;p[h][l]=x;}
if(f%4==0) {l--;x++;p[h][l]=x;}
}
}
for(int i=1;i<=n;i++) {
for(int j=1;j<=n;j++) {
if(p[i][j]<10) cout<<" ";
cout<<p[i][j]<<" ";
}
cout<<endl;
}
return 0;
}
输入:1
输出: 0
输入:2
输出: 0 4746696
0 4629926
输入:3
输出: 0 4746696 0
0 4629926 0
14 9 8
输入:4
输出: 0 4746696 0 5
0 4629926 0 6
14 9 8 7
15 2007766090 0 0
输入:5
输出: 0 4746696 0 5 0
0 4629926 0 6 0
14 9 8 7 2046
15 2007766090 0 0 0
0 4200545 0 268501009 0
输入:6~9
输出:略(懒得打了)
总之就是一堆乱码。。
真感jio这不应该是道红题
我码风不行,大佬们忍一下