📄 zhui.cpp
字号:
#include "graphics.h"
#include "stdio.h"
#include "math.h"
#include "conio.h"
#include "dos.h"
const PI=3.1415926;
double l=25.;
void main(void)
{
float V;
printf("the problem of tracing,\n\n");
printf("copyright(R) by CeKong 0102 ShiShiQiang.\n\n ");
printf("SSQ: please input the speed of the missle:\n\n");
printf("It should be between 0 and 50\n\n");
printf("the speed of the missle is:");
scanf("%f",&V);
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"");
int i=0;
float x,y,X=0.0,Y=0.0,DX,DY,v=V/10.0;
float k,DD,px,py,PX,PY;
setbkcolor(0); /* */
settextstyle(1,0,2); /* */
setcolor(11); /* */
outtextxy(100,10,"press any key to go......"); /*notice: */
getch(); /* V=14, */
setfillstyle(1,0); /* just get */
bar(100,10,500,60); /* target */
outtextxy(100,10,"it is now running after...."); /* */
do
{
setcolor(14);
circle(X,Y,10);
x=i;
y=100*sin(0.5*i*PI/180.0)+100.0;
setcolor(2);
circle(x,y,10);
float t=(x-X)*(x-X)+(y-Y)*(y-Y);
DD=sqrt(t); /* distance of the two circles */
if(Y!=y) /* if the two circles Y is the same */
{
k=(X-x)/(Y-y);
DX=(v*k)/sqrt(1+k*k);
DY=v/sqrt(1+k*k);
}
else
{DX=0;DY=v;}
X=DX+X;
Y=DY+Y;
setcolor(14);
circle(X,Y,10);
if(i>=1)
{
setcolor(0);
circle(px,py,10);
circle(PX,PY,10);
} /* to erase the previous circles */
px=x;py=y;PX=X;PY=Y;
i++;
if(V<=13) /* the speed of the missle is too small */
{ /* to get the target */
if(i==400)
{
settextstyle(1,0,3);
setcolor(6);
outtextxy(317,297,"target lost...");
goto end;
}
}
delay(20);
}while(DD>l);
settextstyle(0,0,5);
setcolor(4);
outtextxy(x+10,y+10,"got it!");
end:
bar(100,10,500,60);
settextstyle(1,0,2);
setcolor(11);
outtextxy(100,10,"press any key to leave.....");
getch();
closegraph();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -