Advertisement
LegoDrifter

Transfomacija na Matrica - Ja resiv sam omg :') :')

Jun 16th, 2020
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include<stdio.h>
  2. #define MAX 100
  3. int main() {
  4.    float mat[100][100];
  5.    float nova[100][100];
  6.    int n;
  7.    scanf("%d",&n);
  8.    float X=0;
  9.    float Y=0;
  10.    for(int i=0;i<n;i++)
  11.    {
  12.        for(int j=0;j<n;j++)
  13.        {
  14.          
  15.            scanf("%f",&mat[i][j]);
  16.            if(i>j)
  17.            {
  18.                 X+=mat[i][j];
  19.            }
  20.            if(i+j>=n)
  21.            {
  22.                 Y+=mat[i][j];
  23.            }
  24.        }
  25.    }
  26.    for(int i=0;i<n;i++)
  27.    {
  28.        for(int j=0;j<n;j++)
  29.        {
  30.            if(i==j)
  31.            {
  32.                nova[i][j]=X;
  33.            }
  34.            if(i+j==n-1)
  35.            {
  36.                nova[i][j]=Y;
  37.            }
  38.            if((i==j)&&(i+j==n-1))
  39.            {
  40.                nova[i][j]=X+Y;
  41.            }
  42.  
  43.        }
  44.        
  45.    }
  46.    for(int i=0;i<n;i++)
  47.    {
  48.        for(int j=0;j<n;j++)
  49.        {
  50.            printf("%.1f ",nova[i][j]);
  51.        }
  52.        printf("\n");
  53.    }
  54.  
  55.   return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement