Two-dimensional array of C language

1  // student achievement issue
 2      // define a two-dimensional array of rows 5 rows and three columns which are stored in a personal three three subjects were stored score 
3      int i, J, S = 0 , Average, v [ . 3 ];
 . 4      int A [ . 5 ] [ . 3 ] = {{ 80 , 75 , 92 }, { 61 is , 65 , 71 is }, { 59 , 63 is , 70 }, { 85 , 87 , 90 }, { 76 , 77 , 85 }};
 5      //GPA perfection component Section and grade point average
 . 6      // [I] [J] 
. 7      for (J = 0 ; J < . 3 ; J ++ ) {
 . 8          for (I = 0 ; I < . 5 ; I ++ ) {
 . 9             S = S + A [I] [J];
 10          }
 . 11          V [J] = S / . 5 ;
 12 is      }
 13 is      Average = V [ 0 ] + V [ . 1 ] + V [ 2 ] / . 3 ;
 14      the printf ( " % D, D%, D% \ n- " , V [ 0 ], V [ . 1],v[2]);
15     printf("%d",average);

===============================================================================================================================================

1      // The two-dimensional array of row exchange element 
2      int A [ 2 ] [ . 3 ] = {{ 1 , 2 , . 3 }, { . 4 , . 5 , . 6 }};
 . 3      int B [ . 3 ] [ 2 ], I, J;
 . 4      // for interchanging rows 
. 5      for (I = 0 ; I < 2 ; I ++ ) {
 . 6          for (J = 0 ; J < . 3 ; J ++ ) {
 . 7              the printf ( " % 5D " , A [I ] [J]);
 8             b[j][i]=a[i][j];
 9         }
10         printf("\n");
11     }
12     //for循环输出B
13     for(j=0;j<3;j++){
14         for(i=0;i<2;i++){
15             printf("%5d",b[j][i]);
16         }
17         printf("\n");
18     }

 

Guess you like

Origin www.cnblogs.com/yh2924/p/12443732.html