找回密码
赶紧注册吧

QQ登录

只需一步,快速开始

当前位置: 交友网 > 技能必杀技 > 生活技能分享 >

C语言如何画图

文章地址: http://www.tflove.com/jineng_sh/a21974.html
文章摘要:
c语言是函数语言,所以画图也离不开各种图形函数:下面举多少个简略的例子: ======================================= 1./*学用circle画圆形*/ #include graphics.h main() {int driver,mode,i; float j=1,k=1; driver=VGA;mode=VGAHI; initgraph(driver,mode,); setbkcolor(YELLOW); for(i=0;ilt;=25;i++) { setcolo
时间:2013-09-20 22:38来源:未知 作者:admin 点击: 次 《C语言如何画图
c语言是函数语言,所以画图也离不开各种图形函数:下面举多少个简略的例子:
=======================================
1./*学用circle画圆形*/
#include "graphics.h"
main()
{int driver,mode,i;
float j=1,k=1;
driver=VGA;mode=VGAHI;
initgraph(&driver,&mode,"");
setbkcolor(YELLOW);
for(i=0;i<=25;i++)
{
setcolor(8);
circle(310,250,k);
k=k+j;
j=j+0.3,C语言如何生成随机数;
}
getch();
}
2.//line画直线
#include "graphics.h"
main()
{int driver,mode,i;
float x0,y0,y1,x1;
float j=12,k;
driver=VGA;mode=VGAHI,C语言如何求素数;
initgraph(&driver,C语言如何才能学好啊?,&mode,"");
setbkcolor(GREEN);
x0=263;y0=263,c语言如何学好;y1=275;x1=275;
for(i=0;i<=18;i++)
{
setcolor(5);
line(x0,y0,x0,y1);
x0=x0-5;
y0=y0-5;
x1=x1+5;
y1=y1+5;
j=j+10;
}
x0=263;y1=275;y0=263;
for(i=0;i<=20;i++)
{
setcolor(5);
line(x0,C语言如何学习。,y0,x0,y1);
x0=x0+5;
y0=y0+5;
y1=y1-5;
}
getch();
}
3.//用rectangle画方形
#include "graphics.h"
main()
{int x0,y0,y1,x1,driver,mode,i;
driver=VGA;mode=VGAHI;
initgraph(&driver,&mode,"");
setbkcolor(YELLOW);
x0=263;y0=263,C语言如何学;y1=275;x1=275;
for(i=0;i<=18;i++)
{
setcolor(1);
rectangle(x0,y0,x1,y1);
x0=x0-5;
y0=y0-5;
x1=x1+5;
y1=y1+5;
}
settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
outtextxy(150,40,"How beautiful it is!");
line(130,60,480,60);
setcolor(2);
circle(269,269,137);
}
===================================
更多有关c语言图形方面的函数及用法请参考c语言图形学的相干常识。 (责任编辑:admin)
分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏0