level 8
Sail丶Man
楼主
~~~~~~~~按ESC可退出程序~~~~~~~~
# include <graphics.h>
# include <conio.h>
# include <time.h>
# include <math.h>
int Quit(void);
int huadian(float * ,float * , int * , int *);
int main(void)
{
float box[2][300];
int a[300]={0};
int b[300]={0};
initgraph(640,480);
srand((unsigned)time(NULL));
for(int i=0; i<300; i++)
box[0][i] = 10 + ((rand() % 31 + 1) - 1) * 20 ;
for(int j=0; j<300; j++)
box[1][j] = 10 + ((rand() % 23 + 1) - 1) * 20 ;
while(true)
{for(int l=0; l<300 ; l++)
huadian(&box[0][l], &box[1][l], &a[l], &b[l]);
Quit();}return 0;}
int Quit(void)
{if(kbhit())
if(27 == getch())
{HWND wnd = GetHWnd();
if(MessageBox(wnd, "你确定要退出吗?","提示", MB_YESNO) == IDYES)
exit(0);}return 0;}
int huadian(float * x, float * y, int * a,int * b)
{setfillcolor(BLACK);
solidcircle(*x,*y,10);
*x = *x + 3 * pow((-1),(*a)) ;
*y = *y + 3 * pow((-1),(*b)) ;
if(*y >= 470) {*b = 1;}
if(*x >= 630) {*a = 1;}
if(*y <= 10) {*b = 0;}
if(*x <= 10) {*a = 0;}
setfillcolor(GREEN);
solidcircle(*x,*y,10);
return 0;}
2013年08月22日 04点08分
1
# include <graphics.h>
# include <conio.h>
# include <time.h>
# include <math.h>
int Quit(void);
int huadian(float * ,float * , int * , int *);
int main(void)
{
float box[2][300];
int a[300]={0};
int b[300]={0};
initgraph(640,480);
srand((unsigned)time(NULL));
for(int i=0; i<300; i++)
box[0][i] = 10 + ((rand() % 31 + 1) - 1) * 20 ;
for(int j=0; j<300; j++)
box[1][j] = 10 + ((rand() % 23 + 1) - 1) * 20 ;
while(true)
{for(int l=0; l<300 ; l++)
huadian(&box[0][l], &box[1][l], &a[l], &b[l]);
Quit();}return 0;}
int Quit(void)
{if(kbhit())
if(27 == getch())
{HWND wnd = GetHWnd();
if(MessageBox(wnd, "你确定要退出吗?","提示", MB_YESNO) == IDYES)
exit(0);}return 0;}
int huadian(float * x, float * y, int * a,int * b)
{setfillcolor(BLACK);
solidcircle(*x,*y,10);
*x = *x + 3 * pow((-1),(*a)) ;
*y = *y + 3 * pow((-1),(*b)) ;
if(*y >= 470) {*b = 1;}
if(*x >= 630) {*a = 1;}
if(*y <= 10) {*b = 0;}
if(*x <= 10) {*a = 0;}
setfillcolor(GREEN);
solidcircle(*x,*y,10);
return 0;}