當前位置:編程學習大全網 - 編程軟體 - C++編程題,求大神指教,實在是小白不會。已知速度和時間和加速度。框架也有了,但是真的不太會

C++編程題,求大神指教,實在是小白不會。已知速度和時間和加速度。框架也有了,但是真的不太會

Firstly, you need bulid up two mathematical equations to calculate the velocity and the acceleration.

double?calculate_velocity(?double&?t?)?{

return?1e-5*t*t*t?-?0.00488*t*t?+?0.75795*t?+?181.3566;

}

double?calculate_acceleration(?double&?v?)?{

return?3.0?-?0.000062*v*v;

}

Secondly, you need to pay attention to the decmial point of your calculated result, which need to fix the length of double variable by

printf(?"Velocity?=?%.3f?m/s\n",?velocity?);

printf(?"Acceleration?=?%.3f?m/s^2\n",?acceleration?);

If you fill in these two pieces of codes inside the original programme, the sample should looks like:

#include?<stdio.h>

#include?<math.h>

double?calculate_velocity(?double&?t?)?{

return?1e-5*t*t*t?-?0.00488*t*t?+?0.75795*t?+?181.3566;

}

double?calculate_acceleration(?double&?v?)?{

return?3.0?-?0.000062*v*v;

}

int?main(?void?)?{

// Declare?variables

double?time;

double?velocity;

double?acceleration;

// Get?time?value?from?the?keyboard

printf(?"Enter?new?time?value?in?seconds:\n");

scanf(?"%lf",?&time?);

// Compute?velocity?and?acceleration

velocity?=?calculate_velocity(?time?);

acceleration?=?calculate_acceleration(?velocity?);

// Print?velocity?and?acceleration

printf(?"Velocity?=?%.3f?m/s\n",?velocity?);

printf(?"Acceleration?=?%.3f?m/s^2\n",?acceleration?);

// Exit?the?program

return?0;

}

The generated result will look exactly as you expected as

  • 上一篇:線性序列是對元素所作的次序的編碼
  • 下一篇:油缸端蓋屬於什麽類零件
  • copyright 2024編程學習大全網