Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
282 views
in Technique[技术] by (71.8m points)

c program run on codeblocks but not on clion how is it even possible?

i successfully run it on codeblocks, but my clion doesnt display anything when i run it. i usually use clion, so im very furious about this. (dont want to be obligated to use codeblocks) please help a poor lost soul. this is the code.

dont have a lot more to say, but still stackoverflow wants me to write more, so here i am.

#include <stdio.h>
#include <stdlib.h>


int **malloc2dR(int r,int c);
int **MATinit(int r, int c);
void MATstampa(int **m, int r, int c);
void change(int **M, int r, int c);

int main() {
    int r=3,c=4;
    int **M=MATinit(r,c);

    MATstampa(M,r,c);
    change(M,r,c);
    MATstampa(M,r,c);

    return 0;
}

int **malloc2dR(int r, int c){
    int **m;
    int i;

    m=malloc(r*sizeof (int *));
    for(i=0;i<r;i++)
        m[i]=malloc(c*sizeof (int));

    return m;
}

int **MATinit(int r, int c){
    int **M=malloc2dR(r,c);
    int i,j;

    printf("scrivere in input i valori della matrice %dx%d
",r,c);

    for(i=0;i<r;i++)
        for(j=0;j<c;j++)
            scanf("%d",&M[i][j]);

    return M;
}

void MATstampa(int **m, int r, int c){
    int i,j;

    for(i=0;i<r;i++) {
        for (j = 0; j < c; j++)
            printf("%d ", m[i][j]);
        printf("
");
    }

    printf("
");
}


void change(int **M, int r, int c) {
    int i, j;
    int ii, jj;
    int **Mfake=malloc2dR(r,c);

    for(i=0;i<r;i++)
        for(j=0;j<c;j++)
            Mfake[i][j]=M[i][j];

    for (i = 0; i < r; i++)
        for (j = 0; j < c; j++)
            if (M[i][j] % 2 == 1) {

                for (ii = 0; ii < r; ii++)
                    Mfake[ii][j] = 1;
                for (jj = 0; jj < c; jj++)
                    Mfake[i][jj] = 1;

            }

    for(i=0;i<r;i++)
        for(j=0;j<c;j++)
            M[i][j]=Mfake[i][j];

}
question from:https://stackoverflow.com/questions/65916842/c-program-run-on-codeblocks-but-not-on-clion-how-is-it-even-possible

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...