数学问题(二)螺旋矩阵

code:https://github.com/lujinjianst/myNCCL/blob/master/exercise/exercise-10.2.c

 

computational results

[haoyue@centos exercise]$ ./a.out
Enter n:6
   1    2    3    4    5    6
  20   21   22   23   24    7
  19   32   33   34   25    8
  18   31   36   35   26    9
  17   30   29   28   27   10
  16   15   14   13   12   11

[haoyue@centos exercise]$ ./a.out
Enter n:10
   1    2    3    4    5    6    7    8    9   10
  36   37   38   39   40   41   42   43   44   11
  35   64   65   66   67   68   69   70   45   12
  34   63   84   85   86   87   88   71   46   13
  33   62   83   96   97   98   89   72   47   14
  32   61   82   95  100   99   90   73   48   15
  31   60   81   94   93   92   91   74   49   16
  30   59   80   79   78   77   76   75   50   17
  29   58   57   56   55   54   53   52   51   18
  28   27   26   25   24   23   22   21   20   19

你可能感兴趣的:(数学问题(二)螺旋矩阵)