float型数组为什么计算得到的结果全是0,是因为没有初始化的原因吗,刚开始学习,如果犯了低级错误,请大佬指出来
float tor[car_num] = {0,0}; float pe[car_num] = { 0,0 };
float pm[car_num] = {0,0};
for (i = 0; i < car_num; i++)
{
temp_1 = p[i];
speed = v[i][temp_1];
gap = FindFront(i);
if (speed + 1 <= vmax)
speed++;
if (speed > gap)
speed = gap;
if (speed > 0 && rand_double() <= pi)
speed--;
if (speed > 0)
v[i][temp_1] = -1;
temp_2 = (temp_1 + speed) % lane; //位置更新
p[i] = temp_2;
v[i][temp_2] = speed;
a[i] = speed - v[i][temp_1];
tor[i] =( mg*(0.0076 + 0.000056*speed) + 0.5*0.3*1.2258*8.25*speed * speed+ 1.1*mg / 10 * a[i])*r; //扭矩
pe[i] = tor[i] / (0.8*0.95*0.8)*(speed / r*0.8*0.9) / 0.8;
pm[i] = pe[i] / 3600;