标签:分享 clu bsp img main log style void .com
/* 4N魔方阵 */ #include<stdio.h> #include<stdlib.h> #define N 8 int main(void){ int i, j; int square[N+1][N+1] = {0}; for(j = 1; j <= N; j++){ for(i = 1; i <= N; i++){ if(j%4 == i%4 || (j%4 + i%4) == 1){ square[i][j] = (N+1-i) * N -j + 1; }else{ square[i][j] = (i-1) * N + j; } } } for(i = 1; i <= N; i++){ for(j = 1; j<= N; j++){ printf("%2d ", square[i][j]); } printf("\n"); } return 0; }
运行结果:
标签:分享 clu bsp img main log style void .com
原文地址:http://www.cnblogs.com/libra-yong/p/6390705.html