#include <stdio.h>
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int i,j;
int x=0,y=5;
int vx=1,vy=1; //速度
int left=0,right=20,top=0,bottom=10; //设置小球运动的边界
while(1)
{
y=x+vx;
y=y+vy;
system("cls");
for(i=0;i<x;x++) //输出空行,每次输出比上一次+1或者-1,实现下降的效果
printf("\n");
for(j=0;j<y;j++); //输出空格,每次输出比上一次+1或者-1,实现移动的效果
printf(" ");
printf("0"); //输出小球
printf("\n");
if(x==top||x==bottom)
vx=-vx;
if(x==left||y==right)
vy=-vy;
}
return 0;
}
#include <stdlib.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int i,j;
int x=0,y=5;
int vx=1,vy=1; //速度
int left=0,right=20,top=0,bottom=10; //设置小球运动的边界
while(1)
{
y=x+vx;
y=y+vy;
system("cls");
for(i=0;i<x;x++) //输出空行,每次输出比上一次+1或者-1,实现下降的效果
printf("\n");
for(j=0;j<y;j++); //输出空格,每次输出比上一次+1或者-1,实现移动的效果
printf(" ");
printf("0"); //输出小球
printf("\n");
if(x==top||x==bottom)
vx=-vx;
if(x==left||y==right)
vy=-vy;
}
return 0;
}