3个回答
展开全部
/*这是一个画抛物线的程序*/
#include<graphics.h>
#define BKC 9
#define COLOR 8 /* 抛物线颜色*/
#define G 9.856
main()
{int gd=DETECT,gm,p=1,i;
double Vx,Vy,x,y,x1,y1,t;
char ch;
initgraph(&gd,&gm,"");
while(p==1) /*主循环体*/
{
setbkcolor(BKC);
setcolor(14);
setlinestyle(0,0,1);
rectangle(0,0,639,479); /*画边框*/
line(20,460,639,460); /*画横坐标*/
line(20,0,20,460); /*画纵坐标*/
outtextxy(8,467,"0");
setlinestyle(1,0,1);
setcolor(15);
for(i=20;i<640;i+=20)line(i,460,i,0);
for(i=460;i>0;i-=20)line(20,i,640,i);
gotoxy(1,1);
printf("Please Enter Vx:" );
scanf("%lf",&Vx);
printf("Please Enter Vy:");
scanf("%lf",&Vy);
for(t=0.0;;t+=0.00002)
{
x=Vx*t;
y=Vy*t-0.5*G*t*t;
x1=2*x+20; /*画笔定位在用户坐标原点 (20,460) */
y1=460-y*2;
if(y1>460.0||x1>640.0) break;
putpixel(x1,y1,COLOR);
}
setcolor(12);
outtextxy(250,8,"Finished! Continue(Y/N)?");
p=-1;
while(p==-1)
{
ch=getch();
if(ch=='y'||ch=='Y') { cleardevice();p=1;}
else if(ch=='n'||ch=='N') p=0;
else outtextxy(220,200,"ERROR! Please Press 'Y' or 'N'_" );
}
}
closegraph();
}
#include<graphics.h>
#define BKC 9
#define COLOR 8 /* 抛物线颜色*/
#define G 9.856
main()
{int gd=DETECT,gm,p=1,i;
double Vx,Vy,x,y,x1,y1,t;
char ch;
initgraph(&gd,&gm,"");
while(p==1) /*主循环体*/
{
setbkcolor(BKC);
setcolor(14);
setlinestyle(0,0,1);
rectangle(0,0,639,479); /*画边框*/
line(20,460,639,460); /*画横坐标*/
line(20,0,20,460); /*画纵坐标*/
outtextxy(8,467,"0");
setlinestyle(1,0,1);
setcolor(15);
for(i=20;i<640;i+=20)line(i,460,i,0);
for(i=460;i>0;i-=20)line(20,i,640,i);
gotoxy(1,1);
printf("Please Enter Vx:" );
scanf("%lf",&Vx);
printf("Please Enter Vy:");
scanf("%lf",&Vy);
for(t=0.0;;t+=0.00002)
{
x=Vx*t;
y=Vy*t-0.5*G*t*t;
x1=2*x+20; /*画笔定位在用户坐标原点 (20,460) */
y1=460-y*2;
if(y1>460.0||x1>640.0) break;
putpixel(x1,y1,COLOR);
}
setcolor(12);
outtextxy(250,8,"Finished! Continue(Y/N)?");
p=-1;
while(p==-1)
{
ch=getch();
if(ch=='y'||ch=='Y') { cleardevice();p=1;}
else if(ch=='n'||ch=='N') p=0;
else outtextxy(220,200,"ERROR! Please Press 'Y' or 'N'_" );
}
}
closegraph();
}
展开全部
根据抛物线类型找到相应公式,然后在纸上先自行解出过程,最后用C语言将过程程序化就可以了 .
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
double x,y;
int a,b,c;
y=ax*x+bx+c
是c语言吧?还是c++,我可只会c哦
int a,b,c;
y=ax*x+bx+c
是c语言吧?还是c++,我可只会c哦
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询