This Blog is dedicated to Sir Johnson Lin
Learn flow chart from C language , master C with the chart!

C language for array[3][4] + array[3][4] = array[3][4]

D:\CPPcode\add2Darray\add2Darray.c++
  1 //++++++++++++++++++++++++++
  2  //      add2Darray.cpp
  3  //++++++++++++++++++++++++++
  4  
  5  ///#include header
  6  #include <stdio.h>
  7  
  8  
  9  ///main_in
 10  int main(void)
 11  {
 12      
 13      
 14      ///declare
 15      int i,j;
 16      int A_class[4][5];
 17      int B_class[4][5];
 18      int Count_AnB[4][5];
 19      
 20      
 21      ///Input Ai Xru 1 to imax
 22      for ( i=1 ; i<=3 ;i++)
 23      {
 24          
 25          
 26          ///Input Aj Xru 1 to jmax
 27          for ( j=1 ; j<=4 ;j++)
 28          {
 29              
 30              
 31              ///Prompt /Keyin
 32              printf( "Enter A_class[%d][%d]: ",i, j); 
 33              scanf("%d", &A_class[i][j]);
 34              
 35              
 36              
 37              ///+
 38          }//end for
 39          
 40          
 41          ///+
 42      }//end for
 43      
 44      
 45      ///Input Bi Xru 1 to imax
 46      for ( i=1 ; i<=3 ;i++)
 47      {
 48          
 49          
 50          ///Input Bj Xru 1 to jmax
 51          for ( j=1 ; j<=4 ;j++)
 52          {
 53              
 54              
 55              ///Prompt /Keyin
 56              printf( "Enter B_class[%d][%d]: ",i, j); 
 57              scanf("%d", &B_class[i][j]);
 58              
 59              
 60              
 61              ///+
 62          }//end for
 63          
 64          
 65          ///+
 66      }//end for
 67      
 68      
 69      ///[AnB]i Xru 1 to imax
 70      for ( i=1 ; i<=3 ;i++)
 71      {
 72          
 73          
 74          ///[AnB]j Xru 1 to jmax
 75          for ( j=1 ; j<=4 ;j++)
 76          {
 77              
 78              
 79              ///Count_AnB[i][j]= A_class[i][j]+ B_class[i][j]
 80              Count_AnB[i][j]= A_class[i][j]+ B_class[i][j];
 81              
 82              
 83              ///Display
 84              printf( "Count_AnB[%d] [%d]=%d; \t",i, j, Count_AnB[i][j]);
 85              
 86              
 87              
 88              ///+
 89          }//end for
 90          
 91          
 92          ///Print newline
 93          printf( "\n");
 94          
 95          
 96          ///+
 97      }//end for
 98      
 99      
100      ///main_end
101      return 0;
102  } //main_end
103  
104  

@ 下載程式碼 Download source code

沒有留言:

張貼留言