数组下标的无效类型“double [100] [double]” [英] Invalid types 'double [100][double]' for array subscript

查看:852
本文介绍了数组下标的无效类型“double [100] [double]”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  #define MAX 100 
双速[MAX];
(itr = 0; itr< velocity [0]; itr = itr + 1)
{
速度[itr] =速度[0] - (1 * itr)
distance [itr] = rk4_solve(itr,velocity);
cout<<< setw(5)< itr< setw(9)<速度[itr]<< setprecision(4)< setw(10)<距离[itr]<< ENDL;
}

我正在尝试将数值输入到数组中,但由于某种原因,我得到错误:i for循环中3行的数组下标的无效类型'double [100] [double]'。

解决方案

itr 必须是 int (或其他整数类型)



请注意,您在for循环中 itr velocity [0] 进行比较( itr< velocity [0]; )。你可能意味着 itr< MAX ,我希望在某个地方定义变量 itr


#define MAX 100 
double velocity[MAX];
for (itr = 0; itr < velocity[0]; itr = itr + 1)
    {
        velocity[itr] = velocity[0] - (1*itr);
        distance[itr] = rk4_solve(itr, velocity);
        cout << setw(5) << itr << setw(9) << velocity[itr] << setprecision(4) << setw(10) << distance[itr] << endl;
    }

I am trying to input values into the array but for some reason I get the error: i Invalid types 'double [100][double]' for array subscript for the 3 lines inside the for loop.

解决方案

itr must be an int (or other integer type)

Be aware that you are comparing itr with velocity[0] in the for cycle (itr < velocity[0];). You probably meant itr < MAX, and I hope somewhere you defined the variable itr

这篇关于数组下标的无效类型“double [100] [double]”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆