Advertisement
LegoDrifter

fix this code for prag 1

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