Advertisement
Guest User

Untitled

a guest
May 17th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int n , arr[100][100] = {0} , i = 0 , j =0;
  4.  
  5. void Nhapmt()
  6. {
  7.     scanf("%d",&n);
  8.     for (i =0 ; i < n ; i++)
  9.     {
  10.         for (j =0 ; j < n ; j++)
  11.         {
  12.             scanf("%d",&arr[i][j]);
  13.         }
  14.     }  
  15.    
  16. }
  17.  
  18. int CotLonNhat()
  19. {
  20.     int tong =0 , max = 0 , temp = 0 ;
  21.     for (i =0 ; i < n ; i++)
  22.     {
  23.         for (j =0 ; j < n ; j++)
  24.         {
  25.             tong += arr[j][i];  
  26.         }
  27.         if (tong > max)
  28.         {
  29.             max = tong ;   
  30.         }
  31.         tong = 0;
  32.     }  
  33.     for (i =n-1 ; i>=0 ; i--)
  34.     {
  35.         for (j =0 ; j < n ; j++)
  36.         {
  37.             tong += arr[j][i];
  38.         }  
  39.         if (tong == max)
  40.         {
  41.             temp = i;  
  42.         }
  43.         tong = 0;
  44.     }
  45.     return temp;
  46. }
  47.  
  48. int main()
  49. {
  50.     Nhapmt();
  51.     printf("%d \n",CotLonNhat() + 1);
  52.    
  53.     for (i =0 ; i < n ; i++)
  54.     {
  55.         for (j =0 ; j < n; j++)
  56.         {
  57.             if (j == CotLonNhat())
  58.             {
  59.                 printf("%d ",arr[i][j]);
  60.            
  61.             }
  62.         }  
  63.        
  64.     }
  65.    
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement