C语言程序设计100个经典例子 联系客服

发布时间 : 星期四 文章C语言程序设计100个经典例子更新完毕开始阅读fe8ac3e242323968011ca300a6c30c225801f001

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,\

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();

}

==============================================================

【程序60】

题目:画图,综合例子。

1.程序分析: 2.程序源代码:

#include \ #define left 0 #define top 0 #define right 639 #define bottom 479 #define lines 400 #define maxcolor 15

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();

} 【程序61】

题目:打印出杨辉三角形(要求打印出10行如下图)

1.程序分析: 1 1 1 1 2 1