#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
int i,j;
int x = 1;
int y = 10;
int height = 20;
int velocuty = 1;
//利用行数实现小球跳跃
while(1)
{
//x控制行,x = x + 1
x = x + velocuty;
system("cls");//清屏
//输出小球上的空行
for(i = 0; i < x;i++)
{
printf("\n");
}
//小球前空格
for(j = 0 ; j < y ; j++)
{
printf(" ");
}
printf("o");
printf("\n");
Sleep(300);
printf("x=%d,y=%d",i,j);
if(x == height)
//坠落的时候x + 1
velocuty = -velocuty;
if(x == 0)
//上升的时候x - 1
velocuty = -velocuty;
}
return 0;
}