www.pudn.com > c.rar > LH.C, change:1980-01-01,size:726b


#include "graphics.h" 
#include "stdlib.h" 
#define MAX 180 
struct DOT 
{ 
int x,y; 
int dx,dy; 
int color; 
}dot[MAX]; 
int init(int i) 
{ 
dot[i].x=320; 
dot[i].y=350; 
dot[i].dx=random(20)-10; 
dot[i].dy=random(20)+10; 
dot[i].color=random(15)+1; 
} 
 
int move(int i) 
{ 
setfillstyle(1,dot[i].color); 
bar(dot[i].x,dot[i].y,dot[i].x+2,dot[i].y+2); 
dot[i].x+=dot[i].dx; 
dot[i].y-=dot[i].dy--; 
} 
 
int main() 
{ 
int graphdriver=VGA,graphmode=VGAMED; 
int page=0; 
initgraph(&graphdriver,&graphmode,""); 
for(page=0;;) 
{int i; 
setactivepage(page); 
cleardevice(); 
for(i=0;i<MAX;i++) 
{move(i); 
if(dot[i].y>350)init(i); 
} 
setvisualpage(page); 
if(kbhit())if(getch()==27) 
break; 
delay(100); 
} 
closegraph(); 
}