国旗代码

#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 + i
arc)r1 + y;
pt[i].x = cos(arcbegin + i
arc)*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();      // 关闭绘图窗口

}

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值