![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
懂C语言的高手进来帮帮忙! 有关计算机图形学,画一辆会动的自行车程序。我的编译没错,可是不能运行。 30
我是用wintc的,帮我改一些。程序如下:/*WIN-TCBGI图形编程模板*/#include"Conio.h"#include"graphics.h"#definec...
我是用win tc的,帮我改一些。程序如下:
/* WIN-TC BGI 图形编程模板 */
#include "Conio.h"
#include "graphics.h"
#define closegr closegraph
void initgr(void) /* BGI初始化 */
{
int gd = DETECT, gm = 0; /* 和gd = VGA,gm = VGAHI是同样效果 */
registerbgidriver(EGAVGA_driver);/* 注册BGI驱动后可以不需要.BGI文件的支持运行 */
initgraph(&gd, &gm, "");
}
int main(void)
{ void *w1,*w2;
int i,k;
int x=500,y=300;
initgr(); /* BGI初始化 */
setbkcolor(6);
/*画前轮*/
circle(x/2,y/2,30);
for(k=0;k<=360;k+=30){
line( x/2,y/2,x/2+30*cos((x/2+k)*0.01745),y/2+30*sin((x/2+k)*0.01745));}
/*画后轮*/
circle(x/2+100,y/2,30);
for(k=0;k<=360;k+=30){
line( x/2+100,y/2,x/2+100+30*cos((x/2+100+k)*0.01745),y/2+30*sin((x/2+100+k)*0.01745));}
circle(x/2+50,y/2,8);
line(x/2+50,y/2,x/2+100,y/2);
line(x/2,y/2,x/2+20,y/2-70);
line(x/2+50,y/2,x/2+80,y/2-60);
line(x/2+100,y/2,x/2+80,y/2-60);
line(x/2+50,y/2,x/2+20,y/2-70);
line(x/2+20,y/2-70,x/2+20,y/2-90);
circle(x/2+20,y/2-90,4);
line(x/2+70,y/2-60,x/2+90,y/2-60);
w1=malloc(imagesize(x/2-130,y/2-90,x/2+130,y/2+30));
getimage(x/2-130,y/2-90,x/2+130,y/2+30,w1);
/*画前轮*/
circle(x/2,y/2,30);
for(k=0;k<=360;k+=30){
line( x/2,y/2,x/2+30*cos((x/2+k)*0.01745),y/2+30*sin((x/2+k)*0.01745));}
/*画后轮*/
circle(x/2+100,y/2,30);
for(k=0;k<=360;k+=30){
line( x/2+100,y/2,x/2+100+30*cos((x/2+100+k)*0.01745),y/2+30*sin((x/2+100+k)*0.01745));}
circle(x/2+50,y/2,8);
line(x/2+50,y/2,x/2+100,y/2);
line(x/2,y/2,x/2+20,y/2-70);
line(x/2+50,y/2,x/2+80,y/2-60);
line(x/2+100,y/2,x/2+80,y/2-60);
line(x/2+50,y/2,x/2+20,y/2-70);
line(x/2+20,y/2-70,x/2+20,y/2-90);
circle(x/2+20,y/2-90,4);
line(x/2+70,y/2-60,x/2+90,y/2-60);
w2=malloc(imagesize(x/2-130,y/2-90,x/2+130,y/2+30));
getimage(x/2-130,y/2-90,x/2+130,y/2+30,w2);
for (i=520;i>0;i--)
{
if (i%2==0)
putimage(i,175,w1,COPY_PUT);
else
putimage(i,175,w2,COPY_PUT);
putimage(i,175,w1,COPY_PUT);
line(0,330,730,330);
}
getch(); /* 暂停一下,看看前面绘图代码的运行结果 */
closegr(); /* 恢复TEXT屏幕模式 */
return 0;
} 展开
/* WIN-TC BGI 图形编程模板 */
#include "Conio.h"
#include "graphics.h"
#define closegr closegraph
void initgr(void) /* BGI初始化 */
{
int gd = DETECT, gm = 0; /* 和gd = VGA,gm = VGAHI是同样效果 */
registerbgidriver(EGAVGA_driver);/* 注册BGI驱动后可以不需要.BGI文件的支持运行 */
initgraph(&gd, &gm, "");
}
int main(void)
{ void *w1,*w2;
int i,k;
int x=500,y=300;
initgr(); /* BGI初始化 */
setbkcolor(6);
/*画前轮*/
circle(x/2,y/2,30);
for(k=0;k<=360;k+=30){
line( x/2,y/2,x/2+30*cos((x/2+k)*0.01745),y/2+30*sin((x/2+k)*0.01745));}
/*画后轮*/
circle(x/2+100,y/2,30);
for(k=0;k<=360;k+=30){
line( x/2+100,y/2,x/2+100+30*cos((x/2+100+k)*0.01745),y/2+30*sin((x/2+100+k)*0.01745));}
circle(x/2+50,y/2,8);
line(x/2+50,y/2,x/2+100,y/2);
line(x/2,y/2,x/2+20,y/2-70);
line(x/2+50,y/2,x/2+80,y/2-60);
line(x/2+100,y/2,x/2+80,y/2-60);
line(x/2+50,y/2,x/2+20,y/2-70);
line(x/2+20,y/2-70,x/2+20,y/2-90);
circle(x/2+20,y/2-90,4);
line(x/2+70,y/2-60,x/2+90,y/2-60);
w1=malloc(imagesize(x/2-130,y/2-90,x/2+130,y/2+30));
getimage(x/2-130,y/2-90,x/2+130,y/2+30,w1);
/*画前轮*/
circle(x/2,y/2,30);
for(k=0;k<=360;k+=30){
line( x/2,y/2,x/2+30*cos((x/2+k)*0.01745),y/2+30*sin((x/2+k)*0.01745));}
/*画后轮*/
circle(x/2+100,y/2,30);
for(k=0;k<=360;k+=30){
line( x/2+100,y/2,x/2+100+30*cos((x/2+100+k)*0.01745),y/2+30*sin((x/2+100+k)*0.01745));}
circle(x/2+50,y/2,8);
line(x/2+50,y/2,x/2+100,y/2);
line(x/2,y/2,x/2+20,y/2-70);
line(x/2+50,y/2,x/2+80,y/2-60);
line(x/2+100,y/2,x/2+80,y/2-60);
line(x/2+50,y/2,x/2+20,y/2-70);
line(x/2+20,y/2-70,x/2+20,y/2-90);
circle(x/2+20,y/2-90,4);
line(x/2+70,y/2-60,x/2+90,y/2-60);
w2=malloc(imagesize(x/2-130,y/2-90,x/2+130,y/2+30));
getimage(x/2-130,y/2-90,x/2+130,y/2+30,w2);
for (i=520;i>0;i--)
{
if (i%2==0)
putimage(i,175,w1,COPY_PUT);
else
putimage(i,175,w2,COPY_PUT);
putimage(i,175,w1,COPY_PUT);
line(0,330,730,330);
}
getch(); /* 暂停一下,看看前面绘图代码的运行结果 */
closegr(); /* 恢复TEXT屏幕模式 */
return 0;
} 展开
1个回答
展开全部
#include<graphics.h>
#include<stdlib.h>
#define PI 3.14159
void WhirlCircle(int x,int y,int r)
{
int i;
clearviewport();
while(!kbhit())
{
for(i=1;i<=21600;i++)
{
if(i%5400==0) setcolor(random(14)+1);
line(x,y,x+r*cos(i*PI/10800),y-r*sin(i*PI/10800));
}
}
getch();
}
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
WhirlCircle(320,240,100);
closegraph();
}
#include<stdlib.h>
#define PI 3.14159
void WhirlCircle(int x,int y,int r)
{
int i;
clearviewport();
while(!kbhit())
{
for(i=1;i<=21600;i++)
{
if(i%5400==0) setcolor(random(14)+1);
line(x,y,x+r*cos(i*PI/10800),y-r*sin(i*PI/10800));
}
}
getch();
}
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"");
WhirlCircle(320,240,100);
closegraph();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询