Advertisement
apl-mhd

maxsuminaRow

Oct 4th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void maxRowSum(int array[3][3]){
  5.  
  6.     int i, j, max = 0, sum=0, address;
  7.  
  8.  
  9.         for(i =0; i<3; i++){
  10.             for(j =0; j<3; j++ ){
  11.  
  12.                 sum += array[i][j];
  13.                 if(max < sum){
  14.                     max = sum;
  15.                     address = i;
  16.                 }
  17.         }
  18.          sum = 0;
  19.     }
  20.  
  21.     //return max;
  22.     printf("maxsum = %d\nMax row = %d\n", max, address );
  23.  
  24.  
  25.  
  26. return;
  27. }
  28.  
  29. int main()
  30. {
  31.     int rowNo;
  32.  
  33.   int number[3][3];
  34.   int i, j;
  35.  
  36.     for(i =0; i<3; i++){
  37.         for(j =0; j<3; j++ ){
  38.                 scanf("%d", &number[i][j]);
  39.  
  40.  
  41.         }
  42.     }
  43.  
  44.  maxRowSum(number);
  45.  
  46.  
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement