平抛运动这个相信读了高中物理都知道这个概念了,详细的我就不说了,不明白的看看百度:
接下来看看用控制台实现的平抛运动算法:
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <fcntl.h>
int main(void)
{
float v0 = 0.01 ;
float g = 9.8 , t , x , s = 0.0, y;
int j ,k , temp;
for(t = 0 ; t < 10 ; t++)
{
x = v0 * t ;
y = 0.5*g*t*t;
s = 0.5*g*t*t;
if(s != 0){
printf("*->x:%.2f y:%.2f",x,y);
temp = t ;
while(temp--)
printf("\n");
printf("|");
Sleep(1000);
}
for(j = 0 ; j < t ; j++){
printf(" ");
}
}
return 0 ;
}
运行结果: