哪个能帮我编程啊,关于这个问题,小弟谢谢
编正n边形的什么问题,能不能说具体点.好象这个问题太宽泛了.比如说给出什么,求什么.你得说清楚啊.
代码如下,我用NEO写的,可以很容易得改成基于graphics.h的,只要将ploy()函数中的画线函数换了就行了,当然main函数里的初始代码也要换成graphics的:
#include "neo.h"
#ifndef PI
#define PI  3.1415926f
#endif
/* x, y为正多边形的中心坐标 */
/* lng为正多边形的边长 */
/* cnt为多边形的边数 */
void ploy(int x, int y, int cnt, int lng)
{
   double art;
   int point_x, point_y;
   int old_x, old_y;
   int R=(int)(lng / 2)/sin(PI / cnt);
   int i;
   if(cnt % 2 == 1) /*判断正多边形边数的奇偶*/
   {
      old_x = 0;
      old_y = R;
      art = PI / 2;
   }
   else
   {
      art = PI / 2 - PI / cnt;
      old_x = (int)(R * cos(art));
      old_y = (int)(R * sin(art));
   }
   for(i = 0; i < cnt; i++)
   {
      art -= (2 * PI) / cnt;
      point_x = (int)(R * cos(art));
      point_y = (int)(R * sin(art));
      line(old_x + x, old_y + y, point_x + x, point_y + y, WHITE);
      old_x = point_x;
      old_y = point_y;
   }
}
main()
{
   neo_init(); /*NEO初使化*/
   set_video_mode(640, 480, 8, 75, 0);  /*设置图形模式*/
   install_keyboard();
   ploy(320, 240, 5, 15);
   ploy(320, 240, 6, 25);
   ploy(320, 240, 7, 35);
   ploy(320, 240, 8, 45);
   ploy(320, 240, 9, 55);
   _getch(); /* 暂停一下,看看前面绘图代码的运行结果 */
}
[此贴子已经被作者于2006-10-16 16:35:29编辑过]