#include<graphics.h>
#include<math.h>
#define FNX(x1) (int)(x+(x1)*s)
#define FNY(y1) (int)(MAXY-(y+y1*s))
#define R(theta) 1-cos(theta)
int s=50,MAXY;
float x1,y1,xs,ys,r,theta;
void draw(int x,int y)
{ for(theta=0;theta<=2*3.1415;theta+=0.01)
{ r=R(theta);
x1=r*sin(theta);
y1=r*cos(theta);
xs=FNX(x1);
ys=FNY(y1);
if(theta==0)moveto(xs,ys);
else lineto(xs,ys);
}
}
main()
{ int gdriver=DETECT,gmode,i;
initgraph(&gdriver,&gmode,"");
setbkcolor(4);
setcolor(2);
MAXY=getmaxy();
draw(280,100);
draw(370,100);
floodfill(310,300,2);
setlinestyle(0,0,3);
for(i=0;i<=1;i++)
for(theta=0;theta<=30;theta+=0.01)
line(180+i,60,180+i+sin(theta)*6,495);
for(i=0;i<9;i++)
{ setlinestyle(0,0,3);
arc(160-5*i,100+50*i,0,150,20+5*i);
}
for(i=0;i<=4;i++)
{ setlinestyle(0,0,3);
arc(190+5*i,100+45*i,360,125,20+5*i);
}
for(i=5;i<=9;i++)
{ setlinestyle(0,0,3);
arc(180+5*i,100+45*i,360,125,20+5*i);
}
for(theta=0;theta<=30;theta+=0.01)
line(510+i,60,510+i+sin(theta)*6,495);
for(i=0;i<9;i++)
{ setlinestyle(0,0,3);
arc(500-5*i,100+50*i,0,150,20+5*i);
}
for(i=0;i<=2;i++)
{ setlinestyle(0,0,3);
arc(530+5*i,100+45*i,360,125,20+5*i);
}
for(i=3;i<=5;i++)
{ setlinestyle(0,0,3);
arc(523+5*i,100+45*i,360,125,20+5*i);
}
for(i=6;i<=9;i++)
{ setlinestyle(0,0,3);
arc(512+5*i,100+45*i,360,125,20+5*i);
}
getch();
closegraph();
}