code:https://github.com/lujinjianst/myNCCL/blob/master/exercise/exercise-14.1.c
computational results:
[haoyue@centos exercise]$ ./a.out
1 2 3 4 5
6 7 8 9 10
11 12 13 14 15
16 17 18 19 20
21 22 23 24 25
***********************************
1 6 11 16 21
2 7 12 17 22
3 8 13 18 23
4 9 14 19 24
5 10 15 20 25
大家可以改成随机输入 5*5 矩阵,或者用srand函数,可以进一步理解矩阵和for循环的应用。