代码如下:
#include"stdio.h"
#include"windows.h"
void play()
{int y = 0,vy = 1;
int x = 0,vx = 1;
int top=0,bottom = 10;
int left=0,right=15;
for(int i=0;i<100;i++)
{for(int j=0;j<y;j++)
printf("\n");
for(int j=0;j<x;j++)
printf(" ");
printf("**");
Sleep(500);
system("cls");
y=y+vy;
if(y == bottom)
vy=-1;
if(y == top)
vy=1;
x=x+vx;
if(x == left)
vx = 1;
if(x == right)
vx = -1;
}
}
int main()
{play();
return 0;
}