C 练习实例59

C 语言教程 · 2019-02-22 08:43:34

题目:画图,综合例子。(在TC中实现)。

程序分析:无。

程序源代码:

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

# define PAI 3.1415926
# define B 0.809
# include "graphics.h"
#include "math.h"
int main()
{
    int i,j,k,x0,y0,x,y,driver,mode;
    float a;
    driver=CGA;mode=CGAC0;
    initgraph(&driver,&mode,"");
    setcolor(3);
    setbkcolor(GREEN);
    x0=150;y0=100;
    circle(x0,y0,10);
    circle(x0,y0,20);
    circle(x0,y0,50);
    for(i=0;i<16;i++)
    {
        a=(2*PAI/16)*i;
        x=ceil(x0+48*cos(a));
        y=ceil(y0+48*sin(a)*B);
        setcolor(2); line(x0,y0,x,y);
    }
    setcolor(3);circle(x0,y0,60);
    /* Make 0 time normal size letters */
    settextstyle(DEFAULT_FONT,HORIZ_DIR,0);
    outtextxy(10,170,"press a key");
    getch();
    setfillstyle(HATCH_FILL,YELLOW);
    floodfill(202,100,WHITE);
    getch();
    for(k=0;k<=500;k++)
    {
        setcolor(3);
        for(i=0;i<=16;i++)
        {
            a=(2*PAI/16)*i+(2*PAI/180)*k;
            x=ceil(x0+48*cos(a));
            y=ceil(y0+48+sin(a)*B);
            setcolor(2); line(x0,y0,x,y);
        }
        for(j=1;j<=50;j++)
        {
            a=(2*PAI/16)*i+(2*PAI/180)*k-1;
            x=ceil(x0+48*cos(a));
            y=ceil(y0+48*sin(a)*B);
            line(x0,y0,x,y);
        }
    }
    restorecrtmode();
}

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

查看所有标签

Learn Python 3 the Hard Way

Learn Python 3 the Hard Way

Zed A. Shaw / Addison / 2017-7-7 / USD 30.74

You Will Learn Python 3! Zed Shaw has perfected the world’s best system for learning Python 3. Follow it and you will succeed—just like the millions of beginners Zed has taught to date! You bring t......一起来看看 《Learn Python 3 the Hard Way》 这本书的介绍吧!

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

在线压缩/解压 JS 代码

在线进制转换器
在线进制转换器

各进制数互转换器

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具