C 实战练习题目65
2020-07-13 06:18
1631 查看
题目:一个最优美的图案(在TC中实现)。
程序分析:无。
程序源代码:
1 #include "graphics.h" 2 #include "math.h" 3 #include "dos.h" 4 #include "conio.h" 5 #include "stdlib.h" 6 #include "stdio.h" 7 #include "stdarg.h" 8 #define MAXPTS 15 9 #define PI 3.1415926 10 struct PTS { 11 int x,y; 12 }; 13 double AspectRatio=0.85; 14 void LineToDemo(void) 15 { 16 struct viewporttype vp; 17 struct PTS points[MAXPTS]; 18 int i, j, h, w, xcenter, ycenter; 19 int radius, angle, step; 20 double rads; 21 printf(" MoveTo / LineTo Demonstration" ); 22 getviewsettings( &vp ); 23 h = vp.bottom - vp.top; 24 w = vp.right - vp.left; 25 xcenter = w / 2; /* Determine the center of circle */ 26 ycenter = h / 2; 27 radius = (h - 30) / (AspectRatio * 2); 28 step = 360 / MAXPTS; /* Determine # of increments */ 29 angle = 0; /* Begin at zero degrees */ 30 for( i=0 ; i<MAXPTS ; ++i ){ /* Determine circle intercepts */ 31 rads = (double)angle * PI / 180.0; /* Convert angle to radians */ 32 points[i].x = xcenter + (int)( cos(rads) * radius ); 33 points[i].y = ycenter - (int)( sin(rads) * radius * AspectRatio ); 34 angle += step; /* Move to next increment */ 35 } 36 circle( xcenter, ycenter, radius ); /* Draw bounding circle */ 37 for( i=0 ; i<MAXPTS ; ++i ){ /* Draw the cords to the circle */ 38 for( j=i ; j<MAXPTS ; ++j ){ /* For each remaining intersect */ 39 moveto(points[i].x, points[i].y); /* Move to beginning of cord */ 40 lineto(points[j].x, points[j].y); /* Draw the cord */ 41 } 42 } 43 } 44 int main() 45 { 46 int driver,mode; 47 driver=CGA;mode=CGAC0; 48 initgraph(&driver,&mode,""); 49 setcolor(3); 50 setbkcolor(GREEN); 51 LineToDemo(); 52 }
感谢你的阅读,请用心感悟!希望可以帮到爱学习的你!!分享也是一种快乐!!!请接力。。。
相关文章推荐
- C 实战练习题目39
- linux运维实战练习-2015年9月10日课程作业
- CSS-浮动(float)-- 全面分析、实战练习、胡说八道哈哈哈
- 在 Anaconda下安装 jupyter 和 numpy,并运行jupyter,完成numpy的20道基本练习题目,熟悉矩阵运算。
- C初级阶段练习题目(三)
- 南阳oj 题目65 另一种阶乘问题
- 2018华为校招机试题目练习
- 10 25日考试 数学题目练习 斐波拉契 打表
- linq to sql + coolite 实战练习项目 手记
- 算法设计与分析题目练习三:骑士旅游问题(回溯算法)
- 大数据技术之_11_HBase学习_03_HBase 实战之谷粒微博(练习API) + 扩展知识(布隆过滤器+HBase2.0 新特性)
- [算法练习] 斐波那契数列 [题目转自飞燕之家]
- 大数据处理例之STL实战练习
- Cocos2D-X学习10:实战练习——一个简单的钢琴
- 数据结构之栈实战练习
- linux运维实战练习-2016年1月19日-2月3日课程作业(练习)
- linux运维实战练习-高级班-2015年10月18日-10月24日课程作业(练习)安排
- C语言之多维数组简单题目练习
- 寻找JAVA练习题目,,速度
- 1089~1096 (练习输入输出的8个题目)