请高手指正下错误
编译下面的程序老是出错,但又找不出问题所在,麻烦大大们修改下错误#include"stdio.h"
#include"math.h"
#include"graphics.h"
#include"stdlib.h"
#include"conio.h"
#define fnx(x) (x20+x*s1)
#define fny(y) (MAXY-y20-y*s1)
#define f(x) exp(-x*x)
#define fpx(x) x+x0
#define fpy(y) y0-y
#define fdx(x) x0-x
#define fdy(y) y+y0int driver=DETECT,mode,x20,y20,MAXX,MAXY;
int xl,yb,xr,yt,x0,y0,a,b,c,d,ch,mx,my;
float s1;
ddaline(x1,y1,x2,y2) /*** 画线函数的DDA方法 ***/
{ int i1;
float x,y,increx,increy,length;
if(abs(x2-x1)>abs(y2-y1))
length=abs(x2-x1);
else length=abs(y2-y1); increx=(x2-x1)/length;
increy=(y2-y1)/length;
x=x1;
y=y1;
for(i1=1;i1<length;i1++)
{ putpixel((int)(x+0.5),(int)(y+0.5),YELLOW); x=x+increx;
y=y+increy;
}}
drawline() /*** 画线的函数 ***/
{ int a,b,c,d;
int driver=DETECT,mode;
printf("Input (x1,y1) and (x2,y2)!\n"); scanf("%d%d%d%d",&a,&b,&c,&d);
initgraph(&driver,&mode,"c:\\tc");
ddaline(a,b,c,d);/*** 调用DDA方法 ***/
getch();
clearviewport(); closegraph();
}pingyi()/*** 平移函数 ***/
{ int xl,yb,xr,yt,driver=DETECT,mode,dx,dy;
int x0,y0;
printf("Input Orgin<int> x0,y0:\n");
scanf("%d%d",&x0,&y0);
printf("Input left(xl,yb) and right(xr,yt):\n");
scanf("%d%d%d%d",&xl,&yb,&xr,&yt);
printf("Input dx and dy:\n");
scanf("%d%d",&dx,&dy);
initgraph(&driver,&mode,"c:\\tc"); setcolor(YELLOW);
orgin(x0,y0);
xl=fpx(xl);xr=fpx(xr);
yb=fpy(yb);yt=fpy(yt);
line(xl,yb,xr,yb);
line(xl,yb,xl,yt);
line(xr,yt,xr,yb);
line(xl,yt,xr,yt);
getch();
xl=xl+dx;xr=xr+dx;
yb=yb-dy;
yt=yt-dy;
line(xl,yb,xr,yb);
line(xl,yb,xl,yt);
line(xr,yt,xr,yb); line(xl,yt,xr,yt);
getch();
closegraph();
}
void setup(void)
{ int driver,mode;
driver=DETECT;
initgraph(&driver,&mode,"c:\\tc"); MAXX=getmaxx();
MAXY=getmaxy();
printf("Input Orgin<int>:x0,y0\t");
scanf("%d%d",&x20,&y20);
printf("Input Multiple:");
scanf("%f",&s1); setviewport(0,0,MAXX,MAXY,1);
}
quxian()/*** 绘制曲线的函数 ***/
{ int xs,ys;
float x,y,x1,y1,x2,y2,dx,i;
setup();
printf("Input x1,x2 and dx: ");
scanf("%f%f%f",&x1,&x2,&dx);
clearviewport();
setcolor(YELLOW); xs=fnx(x1);
ys=fny(0);
moveto(xs-10,ys);
xs=fnx(x2);
lineto(xs+10,ys); xs=fnx(0);
ys=fny(2);
moveto(xs,ys);
ys=fny(0);
lineto(xs,ys);
x=x1;
y=f(x);
xs=fnx(x);
ys=fny(y);
moveto(xs,ys);
for(i=x1;i<x2;i+=dx)
{ x+=dx;
y=f(x);
xs=fnx(x);
ys=fny(y);
lineto(xs,ys);
moveto(xs,ys);
} getch();
clearviewport();
restorecrtmode();
closegraph();
}
bili()/*** 比例变形的函数 ***/
{ int xl,yb,xr,yt,driver=DETECT,mode;
int x0,y0,a,b,c,d;
printf("Input Orgin<int> x0,y0:\n");
scanf("%d%d",&x0,&y0); printf("Input left(xl,yb) and right(xr,yt):\n");
scanf("%d%d%d%d",&xl,&yb,&xr,&yt);
printf("Input bili mx and my:\n");
scanf("%d%d",&mx,&my);
initgraph(&driver,&mode,"c:\\tc");
setcolor(YELLOW);
orgin(x0,y0);
a=xl;b=xr;c=yb;d=yt;
a=fpx(a);b=fpx(b);
c=fpy(c);d=fpy(d); line(a,c,b,c);line(a,c,a,d);line(b,d,b,c);line(a,d,b,d);
getch(); a=xl;
b=xl+(xr-xl)*mx;
c=yb;d=yb+(yt-yb)*my;
a=fpx(a);b=fpx(b);c=fpy(c);
d=fpy(d);
line(a,c,b,c);line(a,c,a,d);line(b,d,b,c);line(a,d,b,d); getch(); closegraph();
}
duix()/*** 关于X轴绘制对称图形 ***/
{ a=xl;b=xr;c=yb;d=yt;
a=fpx(a);b=fpx(b);
c=fdy(c);d=fdy(d);
line(a,c,b,c);line(a,c,a,d);line(b,d,b,c);line(a,d,b,d);
getch();
}duiy()/*** 关于Y轴绘制对称图形 ***/
{ a=xl;b=xr;c=yb;d=yt;
a=fdx(a);b=fdx(b); c=fpy(c);d=fpy(d);
line(a,c,b,c);line(a,c,a,d); line(b,d,b,c);line(a,d,b,d); getch();
}
orgin(x0,y0)/*** 关于原点绘制对称图形 ***/
{ line(0,y0,640,y0); line(x0,0,x0,480);
}
duicheng()/*** 对称函数 ***/
{ printf("Input Orgin<int> x0,y0:\n");
scanf("%d%d",&x0,&y0);
printf("Input left(xl,yb) and right(xr,yt):\n");
scanf("%d%d%d%d",&xl,&yb,&xr,&yt); printf("Select form of change X:1 or Y:2 or Orgin:3!\n");
scanf("%d",&ch); initgraph(&driver,&mode,"c:\\tc");
setcolor(YELLOW);
orgin(x0,y0); a=xl;b=xr;c=yb;d=yt;
a=fpx(a);b=fpx(b); c=fpy(c);d=fpy(d);
line(a,c,b,c);line(a,c,a,d); line(b,d,b,c);line(a,d,b,d);
getch();
switch(ch)/*** 选择对称方式 ***/
{ case 1:duix();break;
case 2:duiy();break;
case 3:duio();break;
default:closegraph();
printf("You input an error data!\n");break;
} getch();
closegraph();
}
fill()/*** 填充函数 ***/
{ int xl,yb,xr,yt,driver=DETECT,mode;
int x0,y0,a,b,c,d,h,w,p[2];
printf("Input Orgin<int> x0,y0:\n");
scanf("%d%d",&x0,&y0);
printf("Input left(xl,yb) and right(xr,yt):\n");
scanf("%d%d%d%d",&xl,&yb,&xr,&yt);
initgraph(&driver,&mode,"c:\\tc");
setcolor(YELLOW);
orgin(x0,y0);
a=xl;b=xr;c=yb;d=yt;
a=fpx(a);b=fpx(b);
c=fpy(c);d=fpy(d);
moveto(a,c);
lineto(b,c); lineto(b,d); lineto(a,d); lineto(a,c);
getch();
for(w=0;w<=640;w++)
for(h=0;h<=480;h++)
{ p[0]=fpx(w);p[1]=fpy(h);
if(a<=p[0]&&p[0]<=b)
if(d<=p[1]&&p[1]<=c) putpixel(p[0],p[1],RED);
} getch();
closegraph();
}
caijian()/*** 裁减函数 ***/
{ int xl,yb,xr,yt,driver=DETECT,mode;
int co,a,b,c; printf("Input the zone that you want to cut out points\nleft(xl,yt) and right(xr,yb):\n");
scanf("%d%d%d%d",&xl,&yt,&xr,&yb);
initgraph(&driver,&mode,"c:\\tc");
setcolor(YELLOW);
for(co=0;co<=400;co+=10) circle(320,240,co);
getch();
c=getbkcolor();
for(a=0;a<=640;a++) for(b=0;b<=yt;b++) putpixel(a,b,c); getch(); for(a=xr;a<=640;a++) for(b=0;b<=480;b++) putpixel(a,b,c); getch(); for(a=0;a<=640;a++) for(b=yb;b<480;b++) putpixel(a,b,c); getch(); for(a=0;a<=xl;a++) for(b=0;b<=480;b++) putpixel(a,b,c); getch(); closegraph();
}
pname()
{
}
pmenu()
{ printf("********************************************************************************"); printf("1:line 2:curve 3:pingyi 4:scale\n"); printf("\n5:symmetry 6:fill 7:jiancai 0:exit\n"); printf("********************************************************************************\n");
}
main(){ int sel;
initgraph(&driver,&mode,"");
closegraph(); loop: pname();
pmenu();
printf("\nSelect the number of operation!\nYour chioce:");
scanf("%d",&sel);
if(sel!=0)
{
switch(sel)
{ case 1:drawline(); break; case 2:quxian(); break; case 3:pingyi(); break; case 4:bili(); break; case 5:duicheng(); break; case 6:fill(); break; case 7:caijian(); break; default:;break; } goto loop; }}
[ 本帖最后由 summer3624 于 2010-6-9 20:05 编辑 ]