为什么会编译错误!!!
查看原帖
为什么会编译错误!!!
1149132
W1661301298楼主2023/12/3 14:36
代码如下****
#include<stdio.h>
#include<math.h>
int main(){
	int n,count=0;
	scanf("%d",&n);
	int a[n][n]={0,};
	for(int i=0;i<ceil(1.0*n/2);i++){
		for(int j=i;j<n-i;j++){
			count++;
			a[i][j]=count;
		}
		if(count==n*n) break;
		for(int j=i+1;j<n-i;j++){
			count++;
			a[j][n-i-1]=count;
		}
		for(int j=n-i-2;j>=i;j--){
			count++;
			a[n-i-1][j]=count;
		}
		for(int j=n-i-2;j>=i+1;j--){
			count++;
			a[j][i]=count;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			printf("%2d ",a[i][j]);
		}
		printf("\n");	
	}
	return 0;
}
2023/12/3 14:36
加载中...