/* Note:Your choice is C IDE */
#include "graphics.h"
#include "stdio.h"
#include "math.h"
void picture1(int X,int Y,float r1,float r2,float x1,float h)
{
setcolor(15);
setlinestyle(0,0,3);
circle(X,Y,r1);
setlinestyle(0,0,3);
line(X-r2,Y,X-r2,Y+x1);
line(X+r2,Y,X+r2,Y+x1);
rectangle(X-3*r2,Y+x1,X+r2,Y+x1+h);
line(X-3*r2,Y+x1,X-r2,Y);
arc(X,Y,0,180,r2);
setcolor(4);
setlinestyle(2,0,0);
line(X-r2-10,Y,X+r2+10,Y);
line(X,Y+r2+10,X,Y-r2-10);
line(X-3*r2+r2-r1,Y+x1,X-3*r2+r2-r1,Y+x1+h);
line(X-3*r2+r2,Y+x1-5,X-3*r2+r2,Y+x1+h+5);
line(X-3*r2+r2+r1,Y+x1,X-3*r2+r2+r1,Y+x1+h);
setcolor(6);
setlinestyle(0,0,3);
rectangle(10,10,630,470);
line(500,420,500,470);
line(500,420,630,420);
setlinestyle(0,0,1);
line(500,445,630,445);line(565,420,565,470);
}
void picture2(int X,int Y,float r1,float r2,float x1,float h)
{ setcolor(15);
setlinestyle(0,0,3);
line(X-3*r2,Y+x1+h+10,X+r2,Y+x1+h+10);
line(X-3*r2,Y+x1+h+10,X-3*r2,Y+x1+h+10+2*r2);
line(X-3*r2+r2,Y+x1+h+10+3*r2,X-3*r2+4*r2,Y+x1+h+10+3*r2);
line(X-3*r2+4*r2,Y+x1+h+10+3*r2,X+r2,Y+x1+h+10);
line(X-3*r2,Y+x1+h+10+r2,X-3*r2+2*r2,Y+x1+h+10+r2);
line(X-3*r2+2*r2,Y+x1+h+10,X-3*r2+2*r2,Y+x1+h+10+2*r2);
line(X-3*r2+2*r2,Y+x1+h+10+2*r2,X-3*r2+2*r2+2*r2,Y+x1+h+10+2*r2);
circle(X-3*r2+r2,Y+x1+h+10+2*r2,r1);
setlinestyle(0,0,3);
arc(X-3*r2+r2,Y+x1+h+10+2*r2,180,270,r2);
setcolor(4);
setlinestyle(2,0,0);
line(X-3*r2+r2-r1-6,Y+x1+h+10+2*r2,X-3*r2+r2+r1+6,Y+x1+h+10+2*r2);
line(X-3*r2+r2,Y+x1+h+10+2*r2-r1-6,X-3*r2+r2,Y+x1+h+10+2*r2+r1+6);
line(X-r1,Y+x1+h+10,X-r1,Y+x1+h+10+2*r2);
line(X+r1,Y+x1+h+10,X+r1,Y+x1+h+10+2*r2);
line(X,Y+x1+h+6,X,Y+x1+h+10+2*r2+6);
}
void picture3(int X,int Y,float r1,float r2,float x1,float h)
{ setcolor(4);
#define aa X+r2+20
#define bb Y-r2
setlinestyle(3,0,0);
line(aa,bb+r2-r1,aa+2*r2,bb+r2-r1);
line(aa,Y+r1,aa+2*r2,Y+r1);
line(aa+2*r2-r1,Y+x1,aa+2*r2-r1,Y+x1+h);
line(aa+2*r2+r1,Y+x1,aa+2*r2+r1,Y+x1+h);
setlinestyle(2,0,0);
line(aa-7,bb+r2,aa+2*r2+7,bb+r2);
line(aa+2*r2,bb+r2+x1-6,aa+2*r2,bb+x1+h+r2+6);
setcolor(15);
setlinestyle(0,0,3);
line(aa,bb,aa,bb+r2+x1+h);
line(aa,bb+r2+x1+h,aa+3*r2,bb+r2+x1+h);
line(aa+3*r2,bb+r2+x1+h,aa+3*r2,bb+r2+x1);
line(aa+3*r2,bb+r2+x1,aa,bb+r2+x1);
line(aa+2*r2,bb+r2+x1,aa+2*r2,bb);
line(aa,bb,aa+2*r2,bb);
line(aa,bb+r2,aa+r2,bb+r2);
line(aa+r2,bb+r2,aa+r2,bb+r2+x1);
}
void fun(int X,int Y,float r1,float r2,float x1,float h,float n)
{
picture1(X,Y,r1*n,r2*n,x1*n,h*n);
}
#include "stdlib.h"
main()
{int X,Y;
float r1,r2,x1,h,n;
int driver=VGA,mode=2;
initgraph(&driver,&mode,"");
setbkcolor(1);
printf("Draw a bolt,input X Y r1 r2 x1 h: ");
scanf("%d%d%f%f%f%f",&X,&Y,&r1,&r2,&x1,&h);
cleardevice();
picture1(X,Y,r1,r2,x1,h);picture2(X,Y,r1,r2,x1,h);picture3(X,Y,r1,r2,x1,h);
getch();
stop:
cleardevice();
printf("input BeiShu n:");
scanf("%f",&n);
cleardevice();
{if (n!=0)
fun(300,200,r1,r2,x1,h,n);
getch();
goto stop;
if (n=0)
printf("skdjfk");
}
}