Advertisement
Josif_tepe

Untitled

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