初学者写了一个小球弹来弹去的代码来玩,但是为什么运行了不到半分钟就不动了啊?

#include
#include
#include
int x = 10, y = 2, v_x = 1, v_y = 1;
int *p = &x;
int *q = &y;
int *vx = &v_x;
int *vy = &v_y;
void object(int x, int y)
{
int i, j;
for (i = 0; i < y; i++)
printf("\n");
for (j = 0; j < x; j++)
printf(" ");
printf("O\n");
}
void move(int *p, int *q, int *vx, int *vy)
{
if ((*q) > 0 && (*q) < 39)
(*q) += (*vy);
else
{
(*vy) = -(*vy);
(*q) += (*vy);
}
if (((*p) + (*vx)) <= 1 || ((*p) + (*vx) >= 100))
{
(*vx) = -(*vx);
(*p) += (*vx);
//(*vx) = rand();
}
else
(*p) += (*vx);
}
void delay()
{
int time1, time2;
time1 = clock();
while (1)
{
time2 = clock();
if (time2 - time1 == 50)
break;
}
}
int main()
{
while (1)
{
system("cls");
object(x, y);
delay();
move(p, q, vx, vy);
}

}

没有特别仔细的看你的代码 但是看到你的方法中 有很多加法操作 是否你的加法操作已经超出了if的边界 所以导致无法移动?