标题:
[讨论]
搞一个程序给大家玩一玩
[打印本页]
作者:
not4weak
时间:
2010-9-9 20:34
标题:
搞一个程序给大家玩一玩
看看能不能编译通过先.
# include <stdlib.h>
# include <graphics.h>
# include <conio.h>
# include <alloc.h>
# define NO 999
# define W 64
# define MAXX 639
# define MAXY 479
# define MAXZ 7
int dot[MAXX+1][3];
char *hf[]={
"11111111111111111111111111111111",
"11111111111111111111111111111111",
"11111111111111111111111111111111",
"11117777777711111177777777711111",
"11117777777771111177111111771111",
"11111111117771111177111111771111",
"11111111117771111177111111771111",
"11117777777771111177111111771111",
"11111111117771111177111111771111",
"11111111117771111177111111771111",
"11117777777771111177111111771111",
"11117777777711111177777777711111",
"11111111111111111111111111111111",
"11111111111111111111111111111111",
"11112233445566776655443322111111",
"11112233445566776655443322111111",
"11111111111111111111111111111111",
"11111111111111111111111111111111",
"11112223344456665443322211111111",
"11112223344456665443322211111111",
"10101010101010101010101010101010",
"01010101010101010101010101010101",
"10101010101010101010101010101010",
"01010101010101010101010101010101"};
void main()
{
int lx,rx,tx;
int gd=0,gm;
int i;
int x,y,h;
int *p;
initgraph(&gd,&gm,"");
for(i=1;i<=8000;i++){
setcolor(i % 8+7);
x=random(MAXX); y=random(MAXY);
line(x,y,x+random(7),y+random(7));
}
p=(int*)malloc(imagesize(0,0,19,1));
for(y=0;y<= MAXY;y+=20){
for(x=0;x<=MAXX;x++){
dot[x][1]=NO;
dot[x][2]=NO;
if (x+W <= MAXX) dot[x][1]= x + W;
if (x-W >= 0) dot[x][2]= x - W;
}
for(h=1;h<=MAXZ;h++){
for(x=0;x<=MAXX;x++){
lx = x - W /2 + h;
rx = x + W / 2 - h;
if (hf[y/20][x/20]-48==h && lx >= 0 && rx <= MAXX){
if (dot[lx][1] !=NO) dot[dot[lx][1]][2]= NO;
dot[lx][1] = rx;
if(dot[rx][2] != NO) dot[dot[rx][2]][1] = NO;
dot[rx][2] = lx;
}
}
}
for(x=0;x<=MAXX;x++){
if(dot[x][2]==NO){
dot[x][0] = x;
tx = x;
while(dot[tx][1]!=NO){
tx = dot[tx][1];
dot[tx][0] = x;
}
}
if(dot[x][0] != x){
getimage(dot[x][0],y,dot[x][0],y+19,p);
putimage(x,y,p,0);
}
}
}
getch();
closegraph();
}
复制代码
作者:
dashxia
时间:
2010-9-10 07:51
What' s this?
欢迎光临 华人论坛 (http://huarenv5.com/forum/)
Powered by Discuz! 7.2