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

查看所有标签

Real-Time Collision Detection

Real-Time Collision Detection

Christer Ericson / CRC Press / 2004-12-22 / USD 98.95

Written by an expert in the game industry, Christer Ericson's new book is a comprehensive guide to the components of efficient real-time collision detection systems. The book provides the tools and kn......一起来看看 《Real-Time Collision Detection》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具