#include <stdio.h>
#include <math.h>
#include <time.h>
#include <Windows.h>
#define half(n) floor(n+0.5)
#define scale 1
#define interval 0.1
#define g 9.8
#define pi 3.1416
#define RAD pi/180
void gotoxy(int x, int y);
double x(double t);
double y(double t);
double theta=60*RAD;
double v0=20;
void main()
{
double t=0;
while(true)
{
gotoxy(2*half(x(t)/scale), 24-half(y(t)/scale)); printf("*");
time_t timer_prev = time(NULL);
while(true)
{
time_t timer = time(NULL);
if(timer>timer_prev+interval) { t += interval; break; }
}
}
}
double x(double t)
{ return v0*cos(theta)*t ; }
double y(double t)
{ return v0*sin(theta)*t - g*t*t/2; }
void gotoxy(int x, int y)
{
COORD cursor;
cursor.X = x;
cursor.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),cursor);
}
댓글 0