多边形裁剪:#include"graphics.h"#define LEFT 1#define RIGHT 2#define BOTTOM 4#define TOP 8#define XL 100.0#define XR 200.0#define YB 100.0#define YT 200.0 encode(float x,float y,int *code) { int c; c=0; if(xXR) c+=RIGHT; if(yYT) c+=TOP; *code=c; return; } main() { int drive,mode; int color,i,j,k,m; int code,code1,code2; float sx,sy,px,py; float fx,fy,x,y; float bx[20],by[20]; float pointx[5]={60.0,130.0,150.0,260.0,180.0}; float pointy[5]={150.0,80.0,140.0,160.0,240.0}; printf("\nColor=\n"); scanf("%d",&color); detectgraph(&drive,&mode); initgraph(&drive,&mode,"c:\\"); setcolor(3); line(XL,YB,XL,YT); line(XL,YB,XR,YB); line(XL,YT,XR,YT); line(XR,YB,XR,YT); setcolor(50); line(XL+300,YB+200,XL+300,YT+200); line(XL+300,YB+200,XR+300,YB+200); line(XL+300,YT+200,XR+300,YT+200); line(XR+300,YB+200,XR+300,YT+200); setcolor(color); line(pointx[4],pointy[4],pointx[0],pointy[0]); for(k=0;k