此代码用于从给定点绘制多边形
我已经导入了winBGIm库,并将这3个文件粘贴到了lib和include中。还更改了编译器中的链接器选项。 它显示错误消息,提示“ program.exe”已停止工作。”并在几秒钟后关闭。
#include<stdio.h>
#include<graphics.h>
using namespace std;
int main()
{
printf("\t\t\t---PROGRAM TO CONVERT GIVEN POINTS TO POLYGON--- \n");
int n,i;
int m=n+2;
printf("\n Enter number of points to be converted to a n-shaped
polygon");
int points[m];
printf("\n Enter the points in the FORMAT(X,Y) for each coordinate");
for(i=0;i<n;i++)
{
scanf("%d",&points[i]);
}
points[n]=points[0];
points[n+1]=points[1];
int gd=DETECT, gm;
initgraph(&gd,&gm,NULL);
int o=n+1;
drawpoly(o ,points);
getch();
closegraph();
}
需要多边形的图形输出