三角函数的应用(外接圆)
三角函数得加上#include<math.h>
绘制正五边形
#include<stdio.h> #include<easyx.h> #include<graphics.h> #include<math.h> #define PI 3.14 int main() { initgraph(400, 400); setbkcolor(RGB(164, 225, 202)); cleardevice(); setaspectratio(1, -1); setorigin(200, 200); double theta = PI / 2;//初始角度 double delta = 2 * PI / 5;//两个点之间相差的角度(每循环一次增加的角度72°) int r = 100; POINT points[5]; for (int i = 0; i < 5; i++) { points[i].x = cos(theta + i * delta) * r; points[i].y = sin(theta + i * delta) * r; } polygon(points, 5); getchar(); closegraph(); return 0; }