中国戏曲音乐集成 pdf:我的程序为何会自动退出

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/28 18:58:42
这是我的部分程序当输入一个数后就自动退出了请问哪有问题
typedef struct{
float x;
float y;
}vertex;
vertex vertices[100];

main()
{
int n;/* the number of vertices */
int i;

int gmode,gdriver=DETECT;
printf("Please input the number of vertices you want(<100):\n");
scanf("%d",&n);
printf("Please input the vertices:\n");
for(i=0;i<n;i++)
{
printf("input the %dth vertex:\n",n+1);
scanf("%f,%f",&vertices[i].x,&vertices[i].y);
}/*get the value of vertices*/

initgraph(&gdriver,&gmode,"");
setviewport(getmaxx()/2, getmaxy()/2, getmaxx(), getmaxy(), CLIP_ON);
for(i=0;i<n-1;i++)
{
setcolor(255);
line(vertices[i].x,vertices[i].y,vertices[i+1].x,vertices[i+1].y);
}
setcolor(255);
line(vertices[n-1].x,vertices[n-1].y,vertices[0].x,vertices[0].y);
/*draw the polygon*/
getch();
closegraph();
}

有些晕,研究中。。。。