代码;
#include<graphics.h>
void bolt(x0,y0,d,l)
int x0,y0,d,l;
{int x1,x2,x3,x4,x5,x6,x7,x8;int y1,y2,y3,y4,y5,r1,r2,b,c;if(l>2*d) b=2*d;else b=1;r1=1.5*d;r2=0.38*d;c=0.1*d;x1=x0-0.7*d;x2=x0-0.61*d;x3=x0-0.32*d;x4=x0+0.8*d;x5=x0+l-b;x6=x0+l-c;x7=x0+l-0.05*d;x8=x0+1;y1=d;y2=0.75*d;y3=0.5*d;y4=0.425*d;y5=0.4*d;setlinestyle(0,0,3);moveto(x2,y0-y3);lineto(x6,y0-y3);lineto(x8,y0-y5);lineto(x8,y0+y5);lineto(x6,y0+y3);lineto(x2,y0+y3);moveto(x2,y0-y1);lineto(x0,y0-y1);lineto(x0,y0+y1);lineto(x2,y0+y1);moveto(x1,y0+y2);lineto(x1,y0-y2);moveto(x5,y0+y3);lineto(x5,y0-y3);moveto(x6,y0+y3);lineto(x6,y0-y3);arc(x3,y0-y2,140,220,r2);setlinestyle(0,0,3);arc(x3,y0+y2,140,220,r2);setlinestyle(0,0,3);arc(x4,y0,160,200,r1);setlinestyle(0,0,1);moveto(x5,y0-y4);lineto(x7,y0-y4);moveto(x5,y0+y4);lineto(x7,y0+y4);setlinestyle(2,0,1);moveto(x1-20,y0);lineto(x8+20,y0);
}
main()
{int x,y,d,l;int gdriver=VGA,gmode=VGAHI;printf("Draw a bolt,input x,y,d,l:");scanf("%d,%d,%d,%d",&x,&y,&d,&l);initgraph(&gdriver,&gmode,"c:\\tc20\\bgi");cleardevice();setbkcolor(9);bolt(x,y,d,l);getch();closegraph();
}
效果图: