自由落体,计算下落距离和速度

/*自由落体,计算下落距离和速度*/
#include<stdio.h>
#include<stdlib.h>
#define GRAVITY 9.81 /*gravitational acceleration(m/s^2)*/

int main(void)
{
double t,y,v; /*time(s),distance of fall(m),final velocity(m/s)*/
printf("\n\nWelcome.\n"
"Calculate the height from which a grapefruit fell\n"
"given the number of seconds that it was falling.\n\n");
printf("Input seconds:");
scanf("%lg",&t);
y=.5*GRAVITY*t*t;
v=GRAVITY*t;
printf("Time of fall=%g seconds\n",t);
printf("Distance of fall=%g meters\n",y);
printf("Velocity of fall=%g m/s\n",v);

system("PAUSE");
return 0;
} /*end main*/

posted @ 2017-03-03 20:50  HGR  阅读(1779)  评论(0编辑  收藏  举报