• C 练习实例65


    [

    C 练习实例65
    C 语言经典100例
    题目:一个最优美的图案(在TC中实现)。
    程序分析:无。
    程序源代码:

    实例

    //  Created by www.runoob.com on 15/11/9.
    //  Copyright © 2015年 Break易站. 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 语言经典100例

    ]
  •   本文标题:C 练习实例65 - Break易站
    转载请保留页面地址:https://www.breakyizhan.com/c-3/19796.html
  • 相关阅读:
    kafka 项目实战
    7.DHCP的相关命令
    3.centos 7执行service iptables save报错问题
    39.NFS(网络文件系统)
    37.Samba 文件共享服务1--配置共享资源
    36.Samba 文件共享服务1--安装及配置参数解释
    35.简单文件传输协议
    34.vsftpd服务程序--虚拟用户模式
    33.vsftpd服务程序--本地用户模式
    32.vsftpd服务程序--匿名开放模式
  • 原文地址:https://www.cnblogs.com/breakyizhan/p/13281210.html
Copyright © 2020-2023  润新知