Traverse Matrix in Diagonal strips

前端 未结 16 1835
暖寄归人
暖寄归人 2020-11-28 02:55

I thought this problem had a trivial solution, couple of for loops and some fancy counters, but apparently it is rather more complicated.

So my question is, how woul

16条回答
  •  攒了一身酷
    2020-11-28 03:35

    I think this can be a solution for any type of matrix.

    #include 
    
    #define M 3
    #define N 4
    
    main(){
             int a[M][N] = {{1, 2, 3, 4}, 
                            {5, 6, 7, 8}, 
                            {9,10,11,12}};
    
             int i, j, t;
             for( t = 0; t=0 ; --i, ++j)
                         if( (i

提交回复
热议问题