私は、小道のアルゴリズムを使用して丘を下って行く車の位置と速度を取得しようとします。しかし、私は得続ける速度ベレットアルゴリズムC++
error: invalid operands of types 'double' and 'double [(((sizetype)(((ssizetype)n) + -1)) + 1)]' to binary 'operator*'|
どうしてですか?
#include <iostream>
#include <cmath>
#include <fstream>
#include <iomanip>
int n=100;
int m=100;
double const gx=0;
double const gy=-9.8;
using namespace std;
int main()
{
int i;
double t[n], x[n], y[n], r[n], vx[n], vy[n], gx[n], gy[n];
double h = 2.0/(n-1), h2=h*h/2, r2, r3;
//double t[0]=0,x[0]=0,y[0]=20;
//double r[0]=x[0],vx[0]=0,vy[0]=0;
double ke[n], mass=1500;
t[0]=0;
x[0]=0;
y[0]=20;
r[0]=x[0];
vx[0]=0;
vy[0]=0;
ke[0]=0;
for(i=0; i<n-1; i++){
t1=t[0]+h;
x[i+1]=x[i]+h*vx[i]+h2*gx;
y[i+1]=y[i]+h*vy[i]+h2*gy;
r2=x[i+1]*x[i+1]+y[i+1]*y[i+1];
r[i+1] = sqrt(r2);
r3=r2*r[i+1];
vx[i]=vx[i]+h*gx/2;
vy[i]=vy[i]+h*gy/2;
cout << t[i+1] << x[i+1] << y[i+1] << r[i+1] << vx[i] << vy[i] << endl;
}
}
なぜ 'std :: vector'の代わりに生の配列を使用していますか? –
'gx'は配列型であり、' double'ではなくエラーです。 –
ありがとうございます。それを私が直した。 –