当前位置:网站首页>Use dichotomy to find specific values from the array
Use dichotomy to find specific values from the array
2022-07-24 07:05:00 【Bubble milk】
#include <stdio.h>
int main()
{
int i = 0;
int arr[] = { 1,2,3,4,5,6,7,8,9,10 };
int sz = sizeof(arr) / sizeof(arr[0]);
int lift = 0;// Left subscript
int right = sz - 1;// Right subscript
scanf("%d", &i);// Receive the number you want to find
while ( lift <= right)
{
int mid = (lift + right) / 2;
if (arr[mid] > i)
right = mid -1;
else if (arr[mid] < i)
lift = mid + 1;
else if (arr[mid] == i)
{
printf(" Subscript to be %d", mid);
break;
}
}
if (lift > right)
printf(" Did not find ");
return 0;
}
// Use dichotomy to find specific numbers from a string of arrays
// Expand your mind : If the contents of the array are large enough , You can find the target faster 边栏推荐
- avaScript的流程控制语句
- 你就是你,没有人可以取代
- lambda表达式对list对象进行多字段排序
- Redis 分片集群
- 10分钟就能写出来的——25~30K的国外企业招聘面试考题,这不是轻轻松松吗~
- The function of extern, static, register, volatile keywords in C language; Nanny level teaching!
- 不去和谁比较,只需做好自己
- [learning notes] possible reasons and optimization methods for white screen on Web pages
- 上传excel文件
- Libc.so.6/glibc cross compilation
猜你喜欢

Penetration learning - SQL injection - shooting range - installation and bypass experiment of safety dog (it will be updated later)
![[learning notes] possible reasons and optimization methods for white screen on Web pages](/img/80/152a2827b0e653ebf2365c16ce3b40.png)
[learning notes] possible reasons and optimization methods for white screen on Web pages

tensorflow einsum函数

Redis 分片集群
![(note sorting is not completed) [graph theory: find the shortest path of single source]](/img/58/e61aea3c4d0a33d3615144763160f7.png)
(note sorting is not completed) [graph theory: find the shortest path of single source]

One book a day: machine learning and practice -- the road to the kaggle competition from scratch

owasp top10 渗透测试

MySQL gets the self incrementing line mark (different from MySQL version)

渗透学习-SQL注入篇-靶场篇-安全狗的安装与绕过实验(后续还会更新)

STM32 external interrupt (register version)
随机推荐
ADB interaction - kill the ugly default shell interface
自己的人生无须浪费在别人的标准中
yocs_ velocity_ Smooth source code compilation
Redis data type -string (string type)
Processing tree structured data
项目问题积累
华为专家自述:如何成为优秀的工程师
Input the names of 10 people and output them in descending order
Huawei experts' self statement: how to become an excellent engineer
Don't compare with anyone, just be yourself
Three level classification / menu query tree structure
[learning notes] Web page rendering process
Mac can't connect to local MySQL server through socket '/tmp/mysql Sock '(2) problem
一首伟大的赞歌
Upload pictures Base64
永远不要迷失自我!
【学习笔记】url输入到页面展现中发生了什么?
Nodejs enables multi process and inter process communication
SPI——发送16位和8位数据
C语言中extern,static, register,volatile 关键字的作用;保姆级教学!