#include <graphics.h> #include <math.h> int main() { int gd = DETECT, gm; initgraph(&gd, &gm, ""); // 设置画笔颜色和填充颜色 setcolor(RED); setfillstyle(SOLID_FILL, RED); // 画绿色的茎 setcolor(GREEN); rectangle(300, 400, 305, 200); floodfill(302, 300, GREEN); // 画红色的花瓣 for (int i = 0; i < 360; i += 10) { double a = i * 3.14 / 180; double r = 100 * sin(3 * a); int x = 400 + r * cos(a); int y = 300 + r * sin(a); circle(x, y, 10); floodfill(x, y, RED); } // 画黄色的花心 setcolor(YELLOW); setfillstyle(SOLID_FILL, YELLOW); circle(400, 300, 30); floodfill(400, 300, YELLOW); getch(); closegraph(); return 0; }检查代码
时间: 2024-03-31 20:34:19 浏览: 20
您的代码看起来没有明显的语法错误,但是您需要确保您的编译环境正确配置了graphics.h库。如果您在编译时遇到任何错误,可以尝试按照以下步骤解决:
1. 确认您的编译器支持graphics.h库,例如Turbo C++或Borland C++等。
2. 确认您已正确包含graphics.h库和math.h库,这需要您的编译器能够找到这些头文件。
3. 确认您已正确链接graphics.h库,这意味着您需要在编译时包含graphics.h库文件。
如果您仍然遇到问题,请提供更多信息,例如您在编译时遇到的错误消息。