128.金刚石图案

简介: 128.金刚石图案
/* diamond */
#include <graphics.h>
#include <math.h>
void main()
{
  float t;
  int x0=320,y0=240;
  int n,i,j,r;
  int x[50],y[50];
  int gdriver=DETECT,gmode;
  printf("Please input n(23<=n<=31) and r(100<=r<=200):\n");
  scanf("%d%d",&n,&r);
  initgraph(&gdriver,&gmode,"c:\\tc");
  cleardevice();
  setcolor(4);
  outtextxy(80,20,"This program show the Diamond picture.");
  t=6.28318/n;
  for(i=0;i<n;i++)
  {
    x[i]=x0+r*cos(i*t);
    y[i]=y0+r*sin(i*t);
  }
  for(i=0;i<=n-2;i++)
  {
    for(j=i+1;j<=n-1;j++)
      line(x[i],y[i],x[j],y[j]);
  }
  outtextxy(80,460,"Press any key to quit...");
  getch();
  closegraph();
}
相关文章
|
3月前
一个最优美的图案
一个最优美的图案。
211 58
|
5月前
|
数据可视化 定位技术 开发者
黑白或彩色线稿地图设计定制装饰画中线条轮廓素材底图获取方法合集
黑白或彩色线稿地图设计定制装饰画中线条轮廓素材底图获取方法合集
|
6月前
颜色拾取器
颜色拾取器
25 0
|
9月前
|
编译器 Windows
<1>[QTCN]颜色拾取器
桌面置顶 获取全局鼠标坐标和颜色(Web值、RGB) 新增: 按下鼠标右键停止/开启
57 1
|
10月前
Photoshop制作空心圆柱体与立体烟缸
Photoshop制作空心圆柱体与立体烟缸
86 0
EasyX颜色+绘制彩虹色天空
今天夜里想搞一搞easyx(doge)
105 0