while 루프를 사용하고 있어야 할 때 종료되지 않습니다. 올바르게 작동하면 randno
이 == highbound
또는 == lowbound
일 때 종료됩니다. 루프While 루프가 종료되지 않습니까?
번호 :
do {
do {
randno = (int) (Math.round((Math.random()*(4)) + 0.5)-1);
direction = getDirection(randno,heading);
} while (robot.look(direction)==IRobot.WALL);
System.out.println(randno);
System.out.println(highbound);
System.out.println(lowbound);
System.out.println("---------------");
} while (randno!=lowbound | randno!=highbound);
출력 어느 3 3 2 ------
또는 2 3 2 ------
이므로 루프가 종료한다. 첫 번째 루프가 제대로 끝납니다 (나는 그것을 삽입하여 작동 시키려고합니다 ...). 무슨 일 이니? randno
이 (가 동일하지 가정) lowbound
및 highbound
모두 동일 할 수 없기 때문에
'while' 루프가 아니며'until' 루프가 아니므로 * 또는 *가 아닌 루프를 계속하려면 lowbound * 및 * highbound와 달라야합니다. –