程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C >> 關於C >> 一個最優美的圖案

一個最優美的圖案

編輯:關於C
程序源代碼: #include "graphics.h" #include "math.h" #include "dos.h" #include "conio.h" #include "stdlib.h" #include "stdio.h" #include "stdarg.h" #define MAXPTS 15 #define PI 3.1415926 struct PTS { int x,y; }; double AspectRatio=0.85; void LineToDemo(void) { struct viewporttype vp; struct PTS points[MAXPTS]; int i, j, h, w, xcenter, ycenter; int radius, angle, step; double rads; printf(" MoveTo / LineTo Demonstration" ); getviewsettings( &vp ); h = vp.bottom - vp.top; w = vp.right - vp.left; xcenter = w / 2; /* Determine the center of circle */ ycenter = h / 2; radius = (h - 30) / (AspectRatio * 2); step = 360 / MAXPTS; /* Determine # of increments */ angle = 0; /* Begin at zero degrees */ for( i=0 ; irads = (double)angle * PI / 180.0; /* Convert angle to radians */ points[i].x = xcenter + (int)( cos(rads) * radius ); points[i].y = ycenter - (int)( sin(rads) * radius * AspectRatio ); angle += step; /* Move to next increment */ } circle( xcenter, ycenter, radius ); /* Draw bounding circle */ for( i=0 ; ifor( j=i ; jmoveto(points[i].x, points[i].y); /* Move to beginning of cord */ lineto(points[j].x, points[j].y); /* Draw the cord */ } } } main() {int driver,mode; driver=CGA;mode=CGAC0; initgraph(&driver,&mode,""); setcolor(3); setbkcolor(GREEN); LineToDemo(); }  *
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved