|
/*金刚石图案*/
#include <graphics.h>
#include <math.h>
#define PATH "d:\\turboc2" /*TC所在路径*/
main()
{
float t;
int x0=320,y0=240;
int n,i,j,r;
int x[50],y[50];
int gdriver=DETECT,gmode;
printf("input n(23-31) and r(100-200)\n");
scanf("%d,%d",&n,&r);
initgraph(&gdriver,&gmode,PATH);
cleardevice();
setbkcolor(9);
setcolor(4);
t=6.28318/n;
for (i=0;i<n;i++)
{
x=r*cos(i*t)+x0;
y=r*sin(i*t)+y0;
}
for (i=0;i<n-1;i++)
for (j=i+1;j<n;j++)
line(x,y,x[j],y[j]);
getch();
closegraph();
} |
|