您的位置:首页 > 编程语言 > ASP

C 实战练习题目65

2020-07-13 06:18 1631 查看

精选30+云产品,助力企业轻松上云!>>>

题目:一个最优美的图案(在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 }

感谢你的阅读,请用心感悟!希望可以帮到爱学习的你!!分享也是一种快乐!!!请接力。。。

点击查看原文,谢谢!

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息