📄 c02p107a.txt
字号:
// Exercise 12int search(int first, int last, int n);int mystery(int n);int main(){ cout << mystery(30) << endl; return 0;} // end mainint search(int first, int last, int n){ int returnValue; cout << "Enter: first = " << first << " last = " << last << endl; int mid = (first + last)/2; if ( (mid * mid <= n) && (n < (mid+1) * (mid+1)) ) returnValue = mid; else if (mid * mid > n) returnValue = search(first, mid-1, n); else returnValue = search(mid+1, last, n); cout << "Leave: first = " << first << " last = " << last << endl; return returnValue;} // end searchint mystery(int n){ return search(1, n, n);} // end mystery
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -