În colaborare cu D0del
#include "graphics2.h"
#include <iostream>
#include <windows.h>
#include <math.h>
#include<fstream>
using namespace std;
int main()
{ifstream f("date");
int driver, mod;
initgraph(&driver, &mod, "", 1300, 800);
double x,v,a,t,xmax,g,i=0,xx;
v=15;
settextstyle(1,HORIZ_DIR,3);
char vv[10];
itoa(v,vv,10);
strcat(vv," m/s");
outtextxy(760,700,vv);
x=0;t=0;a=10;
xmax=30*v*v/20;
cout<<"H max "<<xmax/30<<" m"<<endl<<endl;
cout<<"Timp de urcare/coborare "<<v/a<<" s"<<endl<<endl;
line(750,0,750,1000);
line(0,750,1000,750);
while(x<xmax && x>=0)
{t=t+0.01;
x=(-5*t*t+20*t)*30;
if(x>=0){xx=x;
cout<<x<<" ";
i++;
setcolor(3);
circle(500,700-x,50);
delay(10);
setcolor(0);
circle(500,700-x,50);
}
}
setcolor(3);
circle(500,700-xx,50);
setcolor(15);
line(500,700-x,755,700-x);
char q[10],qq[10];
double pp=xmax/30-(int)xmax/30;
itoa(xmax/30,q,10);
itoa(pp*1000,qq,10);
strcat(q,".");
strcat(q,qq);
outtextxy(760, 700-x,q);
double ti=v/a;
strcat(q," m( ");
strcat(q,itoa(ti,qq,10));
strcat(q,".");
strcat(q,itoa((ti-(int)ti)*
100,qq,10));
strcat(q,"s )");
settextstyle(1,HORIZ_DIR,2);
outtextxy(760, 700-x,q);
delay(2000);
setcolor(0);
circle(500,700-xx,50);
if(v<21){
t=0;x=xmax;
while(x>=-7)
{t=t+0.01;
x=x-(5*t*t)*30;
if(x>=-7){xx=x;
cout<<x<<" ";
i++;
setcolor(3);
circle(500,700-x,50);
delay(20);
setcolor(0);
circle(500,700-x,50);
}
}}
cout<<endl<<" "<<i;
setcolor(3);
circle(500,700-xx,50);
while( !kbhit() );
closegraph();
return 0;
}