标签:style blog color for sp div c log r
Write a code to read and write a matrix in below given way.
Note : no. indicates the sequence here.
I/P
1 2 3
4 5 6
7 8 9
O/P 1
1 4 7
2 5 8
3 6 9
for(i=0;i<row;i++) { for(j=0;j<col;j++) { b[j][i]=a[i][j]; } }
O/P 2
1 6 7
2 5 8
3 4 9
for(i=0;i<row;i++) { for(j=0;j<col;j++) { if(i%2==0) b[j][i]=a[i][j]; else b[j][i]=a[i][col-j-1]; } }
标签:style blog color for sp div c log r
原文地址:http://www.cnblogs.com/leetcode/p/4010382.html