在Visual Studio中引发动态异常

这是代码

int Inverse(double* A, double* B, int N) {

    double  ratio, a;
    int sayac = 0, s =N;
    double** gecici = (double**)malloc(sizeof(double)* s);
    for (int i = 0; i < N; i++)
        gecici[i] = (double*)malloc(s*sizeof(double));for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            gecici[i][j] = A[sayac];
            sayac++;
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = N; j < 2 * N; j++) {
            if (i == (j - N))
                gecici[i][j] = 1.0;
            else
                gecici[i][j] = 0.0;
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i != j) {
                ratio = gecici[j][i] / gecici[i][i];
                for (int k = 0; k < 2 * N; k++) {
                    gecici[j][k] -= ratio * gecici[i][k];
                }
            }
        }
    }
    for (int i = 0; i < N; i++) {
        a = gecici[i][i];
        for (int j = 0; j < 2 * N; j++) {
            gecici[i][j] /= a;
        }
    }

    printf("Inverse\n");
    for (int i = 0; i < N; i++) {
        for (int j = N; j < 2 * N; j++) {
            printf("%.2f", gecici[i][j]);
            printf("\t");
        }
        printf("\n");
    }
    return 0;
}

这是矩阵逆函数的函子gecici表示当我运行两次它表示抛出期望时是暂时的 我正在使用VS,我不知道该说些什么,但是stackoverflow要我说更多,所以我只是从这里写,就像我说它的功能是寻找矩阵的逆,但是当我运行它时,它会导致断点,而当我发送垃圾邮件时继续其开始再次工作,但仅用于exe可能会引起问题,请紧急解决。

评论