josiftepe

Untitled

Jan 8th, 2021
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. #include <stdio.h>
  2. #define MAX 100
  3.  
  4. int main(){
  5.     int mat[MAX][MAX];
  6.  
  7.     int n,m,i,j , indexi,indexj;
  8.     int sum[4]={0};
  9.     scanf("%d %d",&n,&m);
  10.     for (i=0;i<n;i++){
  11.         for (j=0;j<m;j++){
  12.             scanf("%d",&mat[i][j]);
  13.         }
  14.  
  15.     }
  16.     scanf("%d %d",&indexi,&indexj);
  17.  
  18.     for (i=0;i<n;i++){
  19.         for (j=0;j<m;j++){
  20.             if (i < indexi && j < indexj){
  21.                 sum[1]+=mat[i][j];
  22.             }
  23.             else if (i < indexi && j >= indexj){
  24.                 sum[0]+=mat[i][j];
  25.             }
  26.             else if (i >= indexi && j < indexj){
  27.                 sum[2]+=mat[i][j];
  28.             }
  29.             else if (i >= indexi && j >= indexj){
  30.                 sum[3]+=mat[i][j];
  31.             }
  32.         }
  33.  
  34.     }
  35.  
  36.  
  37.     for (i=0;i<4;i++){
  38.             printf("%d ",sum[i]);
  39.         }
  40.     return 0;
  41.  
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment