C 练习实例65

C 语言教程 · 2019-02-22 10:12:00

题目:一个最优美的图案(在TC中实现)。

程序分析:无。

程序源代码:

//  Created by www.codercto.com on 15/11/9.
//  Copyright © 2015年 码农教程. All rights reserved.
//

#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 ; i<MAXPTS ; ++i ){ /* Determine circle intercepts */
        rads = (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 ; i<MAXPTS ; ++i ){ /* Draw the cords to the circle */
        for( j=i ; j<MAXPTS ; ++j ){ /* For each remaining intersect */
            moveto(points[i].x, points[i].y); /* Move to beginning of cord */
            lineto(points[j].x, points[j].y); /* Draw the cord */
        }
    }
}
int main()
{
    int driver,mode;
    driver=CGA;mode=CGAC0;
    initgraph(&driver,&mode,"");
    setcolor(3);
    setbkcolor(GREEN);
    LineToDemo();
}

点击查看所有 C 语言教程 文章: https://www.codercto.com/courses/l/17.html

查看所有标签

我是一只IT小小鸟

我是一只IT小小鸟

胡江堂、李成、唐雅薇、秦琴、蒋宇东、刘未鹏、居振梁、刘帅、温卫斌、张弦、张凯峰、庄表伟、宋劲杉、程露、黄小明、易晓东、简朝阳、林健、高昂、徐宥、辜新星 / 电子工业出版社 / 2009 / 29.80

一群IT小小鸟—— 来自十几所院校,或男生,或女生;或科班,或半路转行。 分布在不同的公司,或外企,或国企,或民企,老板有土有洋。 有失意,有快意;有泪水,有欢笑。在失望中追求希望,在迷茫中辨别方向。 他们用自己的成长故事,告诉在校的师弟师妹们: 青春太宝贵,千万别浪费;要想不浪费,万事早准备。一起来看看 《我是一只IT小小鸟》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

MD5 加密
MD5 加密

MD5 加密工具