gpt4 book ai didi

c++ - 将矩阵复制到 C++ 中指针指向的位置

转载 作者:行者123 更新时间:2023-11-28 07:25:04 25 4
gpt4 key购买 nike

如何将矩阵复制到指针指向的位置?

我是 C++ 的新手。我尝试了很多,但找不到任何解决方案。

这是我的代码:

float *output = new float[HighRange];
output = new float[10 * 10];

for(int i=0; i<10; i++){
for(int j=0; j<10; j++){
output[j]=input[i][j]; ---> I have error in this line

提前致谢

最佳答案

outputinput的元素有多种排列方式。这是一种方法:

output[i*10 + j] = input[i][j]

关于c++ - 将矩阵复制到 C++ 中指针指向的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18898920/

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