c语言60,C 练习实例60

C 练习实例60

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

程序分析:无。

程序源代码:

// Created by www.runoob.com on 15/11/9.

// Copyright © 2015年 菜鸟教程. All rights reserved.

//

#include "graphics.h"

#define LEFT 0

#define TOP 0

#define RIGHT 639

#define BOTTOM 479

#define LINES 400

#define MAXCOLOR 15

int main()

{

int driver,mode,error;

int x1,y1;

int x2,y2;

int dx1,dy1,dx2,dy2,i=1;

int count=0;

int color=0;

driver=VGA;

mode=VGAHI;

initgraph(&driver,&mode,"");

x1=x2=y1=y2=10;

dx1=dy1=2;

dx2=dy2=3;

while(!kbhit())

{

line(x1,y1,x2,y2);

x1+=dx1;y1+=dy1;

x2+=dx2;y2+dy2;

if(x1<=LEFT||x1>=RIGHT)

dx1=-dx1;

if(y1<=TOP||y1>=BOTTOM)

dy1=-dy1;

if(x2<=LEFT||x2>=RIGHT)

dx2=-dx2;

if(y2<=TOP||y2>=BOTTOM)

dy2=-dy2;

if(++count>LINES)

{

setcolor(color);

color=(color>=MAXCOLOR)?0:++color;

}

}

closegraph();

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值