好吧,这是一个更多的查询,所以我可以理解这是做什么,但是,我有以下代码.因为,while循环将返回一个无限循环,我将while更改为一个基本for(int i=0;i<n;i++)循环,它正常工作和输出.
怎么了?我实际上不知道为什么我的while循环会卡住但for循环不会.
bool binary_search(const string A[], int n, string name, int &count){
count = 0; // Count initialization
int fst = 0;
int lst = n+1; // First, Last and Middle array elements
int mid = 0;
while(fst<=lst)
{
count++;
mid = (fst+lst)/2; // Calculate mid point of array
if (A[mid]==name) // If value is found at mid
{
return true;
}
else if (A[mid]>name)
{ // if value is in lower
lst = mid++;
//cout << …Run Code Online (Sandbox Code Playgroud) 我正在使用 fullpage.js 开发一个网站: https: //github.com/alvarotrigo/fullPage.js/
我遇到的第一个问题是,一旦箭头落入最后一部分和/或幻灯片,我需要隐藏箭头。IE。如果您在最右侧的幻灯片上,我希望它会隐藏右侧箭头。顶部部分、顶部箭头被隐藏等。
我已经尝试了很多让它工作,我仍在学习 javascript,所以如果我离得很远,请原谅我,但我希望这很接近:
function hideArrowUp() {
if(index == 1){
$('.arrowUp').hide();
}
else {
$('.arrowUp').show();
}
}
function hideArrowDown(anchorlink) {
if(index == 3){
$('.arrowDown').hide();
}
else {
$('.arrowDown').show();
}
}
Run Code Online (Sandbox Code Playgroud)
我希望防止水平幻灯片重复/翻转,不确定这是否容易。
请并谢谢!