所谓奇数魔幻矩阵就是n*n的矩阵(n为奇数)变换成行,列以及对角线的和都相等! 首先了解其生成法则: 1 ,第一个数字在第一行的中间位置 2,在最新插入的右上角插入接下来的数,如果向上超出了界限,在最行的最后一行插入,如果右超出了界限,在行的最左边插入 3.如果插入数为n的倍数,则在列下放插入
程序 :
#include
"
stdlib.h
"
#include " stdio.h "
#include " time.h "
int ** arrMetrix ; // the magic metrix
int n ; // the v
void createMagicMetrix () // depend on the rule to create magic metrix to create metrix
{
int num = 1 ;
arrMetrix[ 0 ][n / 2 ]
#include " stdio.h "
#include " time.h "
int ** arrMetrix ; // the magic metrix
int n ; // the v
void createMagicMetrix () // depend on the rule to create magic metrix to create metrix
{
int num = 1 ;
arrMetrix[ 0 ][n / 2 ]