Advertisement
LegoDrifter

Matrici - Prag

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