#include <graphics.h> // 引用图形库头文件
#include <math.h>
#include<conio.h>
const double PI = 3.1415927;
void DrawStar(int x, int y, int R, double arcbegin)
{
POINT pt[10];
double r = Rsin(18 * PI / 180) / sin(126 * PI / 180);
double arc = PI / 5.0;
double r1;
for (int i = 0; i < 10; ++i)
{
if (i % 2 == 0)
r1 = R;
else
r1 = r;
pt[i].y = sin(arcbegin + iarc)r1 + y;
pt[i].x = cos(arcbegin + iarc)*r1 + x;
}
setfillcolor(RGB(255, 255, 0));
setcolor(RGB(255, 255, 0));
fillpolygon(pt, 10);
}
int main()
{
initgraph(900, 600); // 创建绘图窗口,大小为 900x600像素
setfillcolor(RGB(235, 0, 0));
setcolor(RGB(255, 255, 0));
fillrectangle(0, 0, 900, 600);
DrawStar(150, 150, 90, -PI / 2);
DrawStar(300, 60, 30, -PI / 2 + atan(3.0 / 5.0));
DrawStar(360, 120, 30, -PI / 2 + atan(1.0 / 7.0));
DrawStar(360, 210, 30, -PI / 2);
DrawStar(300, 270, 30, -PI / 2 + atan(3.0 / 5.0));
_getch();//按任意键继续
closegraph(); // 关闭绘图窗口
}