我想知道斷點有多少次被擊中。Java - 斷點多少次?
問題提出:對於前4個點擊中的每一個,記下currentMin的值,當前的最大值和中間值,可以在調試器中看到。
我的值是:n = 40,currentMin = 0,currentMax = 40,mid = 20。
這四個命中?或者我需要使用上述值四次循環四次?
public class Breakpoint {
public int breakp() {
int n = 40;
int currentMin = 0;
int currentMax = n;
while (currentMin < currentMax) {
int mid = (currentMin + currentMax)/2;
if (mid * mid + mid + 1 <= n)//breakpoint is on this line {
currentMin = mid;
} else {
currentMax = mid;
}
}
return currentMin;
}
public static void main(String[] args) {
Breakpoint b = new Breakpoint();
int a = b.breakp();
System.out.println(a);
}
}
我覺得這是一個有點混亂,因爲該類也叫「斷點」 。我假設問題指向你的while循環中的某個斷點? – phatfingers 2012-08-11 15:48:54
對不起忘了添加斷點放在第5行和n的值爲40 – nsc010 2012-08-11 15:51:13