===============
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int r,x1=320,x2,y1=240,y2;
float a;
initgraph(&gdriver, &gmode, “”); //Инициализируем графический режим
//ПРОВЕРКА НА ОШИБКИ
errorcode = graphresult();
if (errorcode != grOk)
{
printf(“Graphics error: %s\n”, grapherrormsg(errorcode));
printf(“Press any key to halt:”);
getch();
exit(1); //В случае обнаружения ошибки выход из программы
}
r=3; //Задаем радиус спирали
a=0;
moveto(x1,y1); //Перемещаем курсор в точку начала построения спирали
do {
x2=x1-(r*a*sin(a));
y2=y1+(r*a*cos(a));
lineto(x2,y2);
a+=0.01;
} while (a<=360); //Длина спирали зависит от конечного значения
/* clean up */
getch();
closegraph();
return 0;
}
=============