- int mid;
- int x = 0, y = n-1;
- bool flag = 0;
- while(x <= y)
- {
- mid = x+(y-x)/2;
- if(ls[mid] == key)
- {
- printf("%d\n",mid+1);
- flag = 1;
- break;
- }
- else if(ls[mid] > key)
- y = mid - 1;
- else
- x = mid+1;
- }
- if(!flag)
- printf("No Found!\n");
二分————
最新推荐文章于 2024-05-02 11:04:08 发布