蛇形方阵的程序
c语言吧
全部回复
仅看楼主
level 1
fdp47 楼主
蛇形方阵是由1--n的平方组成的方阵,例如4阶蛇形方阵1   2   3   48   7  6   59  10   11  1216  15  14  13
#include "stdio.h"#
include "conio.h"main(){ int a[15][15]={0}; int i,j,n=0,count; while(n<1 || n>15) { printf("请输入蛇形方阵的阶数(<16): "); scanf("%d",&n); } i=0;j=-1; for (count=1;count<=n*n;) { while (j
0 && a[i][j-1]==0) a[i][--j]=count++; if (i>0 && a[i-1][j]==0) a[--i][j]=count++; } for (i=0;i
2006年02月06日 08点02分 1
1