循环无法退出,求解决办法
以下是编码的一部分,第一个while循环无法退出,到底是哪里出了错,或者用什么办法能退出循环int youxi(int * ysz, int * bsz,int x1, int y1,int x2,int y2){
int a, b,i=0,j=0,c=0,q1,q2,w1,w2;
a = (4 * x1 + y1 - 5);
b = (4 * x2 + y2 - 5);
system("cls");
while (*(ysz + a) == *(ysz + b)){
*(bsz + a) = *(ysz + a);
*(bsz + b) = *(ysz + b);
for (i = 0; i<4; i++)
{
for (j = 0; j<4; j++)
printf("%5c", *(bsz + 4*i +j));
printf("\n\n");
}
printf("you guss right!\n enter the first site (x,y)\n first press x ");
scanf("%d,", &x1);
printf("then press y ");
scanf("%d", &y1);
printf("enter the second site (x,y)\nfirst press x ");
scanf("%d,", &x2);
printf("then press y ");
scanf("%d", &y2);
system("cls");
}
while (*(ysz + a) != *(ysz + b))
{
*(bsz + a) = *(ysz + a);
*(bsz + b) = *(ysz + b);
for (i = 0; i < 4; i++)
{
for (j = 0; j < 4; j++)
printf("%5c", *(bsz +4 * i+j));
printf("\n\n");
}
Sleep(2000);
system("cls");
*(bsz + a) = 5;
*(bsz + b) = 5;
for (i = 0; i < 4; i++)
{
for (j = 0; j < 4; j++)
printf("%5c", *(bsz + 4 * i + j));
printf("\n\n");
}
printf("you guss wrong, try again\n");
printf("enter the first site (x,y)\nfirst press x ");
scanf("%d,", &x1);
printf("then press y ");
scanf("%d", &y1);
printf("enter the second site (x,y)\nfirst press x ");
scanf("%d,", &x2);
printf("then press y ");
scanf("%d", &y2);
}
return 0;
}
[此贴子已经被作者于2015-11-19 19:16编辑过]