gpt4 book ai didi

c++ - 在代码块中需要帮助

转载 作者:行者123 更新时间:2023-11-28 06:58:17 26 4
gpt4 key购买 nike

<分区>


此代码在 Visual C++ 中执行成功,但在代码中显示运行时错误返回“进​​程终止,状态为 -1073741819”的 block 。另外当 MAX 是定义为“#define MAX 4”它成功执行。有人可以帮忙吗?谢谢!


#include <iostream>
#include <cstdlib>
#define MAX 32

using namespace std;

double **A, **B, **C;

void initialize(double** x) //code to initialize matrix
{
static int n = 0;

for(int i = 0; i < MAX; i++)
*(x+i) = (double*) new double[MAX];

srand(n);
double* ptr = *x;

for(int i = 0; i < MAX; i++)
for(int j = 0; j < MAX; j++)
*(ptr+(i*MAX)+j) = rand() % 100;

n++;
}

void print(double** x)
{
double* ptr = *x;

for(int i = 0; i < MAX; i++){
for(int j = 0; j < MAX; j++)
cout<<*(ptr+(i*MAX)+j)<<" ";
cout<<endl;
}
}

int main(){
A = (double**) new double[MAX];
B = (double**) new double[MAX];
C = (double**) new double[MAX];

initialize(A);
initialize(B);
initialize(C);

print(A);
cout<<endl;
print(B);
cout<<endl;
print(C);
cout<<endl;
system("pause");
return 0;
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com