Rookie C language OJ can't run locally. What can we do?

int Setbit(int* A,int RowSize){
    int i = 0;int Sum = 0;
    for(i = 0;i < RowSize;iPP)
        if(A[i] == 0)
        Sum ^= 1<<(RowSize-i-1);
    return Sum;
}//Setbit;

bool Readbit(int S,int i,int RowSize){
    return S&( 1 <<  (RowSize-1-i));
}//readbit;

void setzero(int** matrix,int RowSize,int ColSize,int Col, int Row){
    int Z = 0;
    for(Z = 0; Z < RowSize;Z PP)  *(*(matrix+Col)+Z) = 0; 
    for(Z = 0;Z < ColSize;Z PP) *(*(matrix+Z)+Row) = 0;
}//setzero

void setZeroes(int** matrix, int matrixRowSize, int matrixColSize) {
    
    int a,b,c;int Z = 0;
    a = 0;b = c = 0;
    int *s = (int*)calloc(matrixColSize,sizeof(int));
    for(a = 0; a < matrixColSize; aPP){
        int *A = (int*)malloc(sizeof(int)*matrixRowSize);
        memcpy(A,matrix[a],matrixRowSize*sizeof(int));
        s[a] = Setbit(A,matrixRowSize);    
    }//setbit
    
    for(a = 0; a < matrixColSize; aPP){
        if(s[a] !=0 ) 
            for(b = 0; b < matrixRowSize; bPP)
                if( Readbit(s[a],b,matrixRowSize))
                setzero(matrix,matrixRowSize,matrixColSize,a,b);    
    }
    free(s);
}
int main(){
    
        int N,M;int i,j;i = j = 0;
    scanf("%d %d",&N,&M);
    int **matrix = (int**)malloc(sizeof(int*)*N);
    for(i = 0; i < N;i PP){
        matrix[i] = (int*)calloc(M,sizeof(int));
        for(j = 0; j < M; jPP){
            scanf("%d",&matrix[i][j]);
        }
    }        
    printf("N === %d M === %d\n",N,M);
    for(i = 0; i < N; iPP){
        for( j = 0; j < M; j PP){
            printf("matrix[%d][%d] == %d\t",i,j,matrix[i][j]);
        }
        printf("\n");
    }//
    
    setZeroes(matrix,M,N);
    
    for(i = 0; i < N; iPP){
        for( j = 0; j < M; j PP){
            printf("matrix[%d][%d] == %d\t",i,j,matrix[i][j]);
        }
        printf("\n");
    }//
    return 0;
}

I would like to ask, the usual use of Ubuntu14.04 programming, every time encounter the same problem, how to debug locally, with those commands.

CPP c
Mar.07,2021

do not rely too much on the test tool for oj (for example, single-step debugger), generally has the following solutions:

  1. naked eye
  2. printf type log, such as input intermediate quantity, to see where the problem occurs.
  3. push down and rewrite
  4. if it is for comparison, and debug. is better than the environment that provides gdb, or cb/devcpp, is as familiar as the corresponding environment

when it comes to your code, the finished file can be typed on gcc. If you still can't do it locally, check out your environment (editor) and output information.

in addition, provide the possibility of out-of-the-box:

  1. if the environment of c is c89 ansi 90 or bool c, then bool cannot be used. Since the bool of c is only available in c99, if there is no -sharpinclude < stdbool.h > , then you need _ Bool to demonstrate, -sharpinclude < stdbool.h > to do typedef , you can directly write bool .
  2. you may use it locally and then gPP edit cpp instead of .c, so use gcc editing .c locally. Or the online environment is also cut to cPP,. No matter how to keep the local and online environments consistent, cut c and cPP are completely different languages for departments , so don't mix them up, even if you happen to be able to edit the same document from time to time.
  3. you used -sharpinclude < bits/stdcPP.h > , so you missed the missing file when gluing online.

finally, only one of c and cPP is retained in the tag, not both.


if you are not deliberately learning Linux, it is not recommended to use ubuntu to do these exercises. It is good to use visual studio under windows. If you must use Ubuntu, you need to install similar IDE, such as Eclipse,QT Creator, otherwise you will be tired to debug with gdb.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e802cb-ab8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e802cb-ab8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?