×
C 语言教程C 简介C 环境设置C 程序结构C 基本语法C 数据类型C 变量C 常量C 存储类C 运算符C 判断C 循环C 函数C 作用域规则C 数组C 指针C 函数指针与回调函数C 字符串C 结构体C 共用体C 位域C typedefC 输入 & 输出C 文件读写C 预处理器C 头文件C 强制类型转换C 错误处理C 递归C 可变参数C 内存管理C 命令行参数C 语言实例C 经典100例

C 标准库

C 标准库 - 参考手册C 标准库 - <assert.h>C 标准库 - <ctype.h>C 标准库 - <errno.h>C 标准库 - <float.h>C 标准库 - <limits.h>C 标准库 - <locale.h>C 标准库 - <math.h>C 标准库 - <setjmp.h>C 标准库 - <signal.h>C 标准库 - <stdarg.h>C 标准库 - <stddef.h>C 标准库 - <stdio.h>C 标准库 - <stdlib.h>C 标准库 - <string.h>C 标准库 - <time.h>

C 练习实例65:一个最优美的图案(在TC中实现)


C 语言经典100例C 语言经典100例


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

程序分析:无。

程序源代码:

//  Created by www.waitang.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 语言经典100例C 语言经典100例


分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)