?? d.c
字號:
#include<graphics.h>
#include<math.h>
void polygon();
main()
{
int i,a,x,y;
float af;
int gdriver=DETECT,gmode;
printf("input length of polygon:a=");
scanf("%d",&a);
printf("\ninput position point:\nx=");
scanf("%d",&x);
printf("y=");
scanf("%d",&y);
printf("\ninput angle of polygon:af=");
scanf("%f",&af);
initgraph(&gdriver,&gmode,"c:\\tc");
cleardevice();
setbkcolor(9);setcolor(4);
for(i=3;i<=10;i++)
polygon(x,y,a,i,af);
getch();
closegraph();
}
void polygon(int x0,int y0,int a,int n,float af)
{
int x,y,i;
float dtheta,theta;
if(n<3) return;
dtheta=6.28314/n;
theta=af*0.0174533;
moveto(x0,y0);
x=x0;y=y0;
for(i=1;i<n;i++) {
x=x+a*cos(theta); y=y+a*sin(theta);
lineto(x,y); theta+=dtheta;
}
lineto(x0,y0);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -