当前位置:网站首页>顺序表查找
顺序表查找
2022-06-23 03:44:00 【@风景邮递Yuan】
顺序查找
int Sequential_Search ( int *a, int n, int key ) {
int i;
for (i = 1; i <= n; i++) {
if (a[i] == key )
return i;
}
return 0;
}int Sequential_Search2 ( int *a, int n, int key ) {
int i;
/* 设 置 a[0] 为 关 键 字 值 , 我 们 称 之 为 “ 哨 兵 ” */
a[0] = key ;
/* 循 环 从 数 组 尾 部 开 始 */
i = n;
while (a[i] != key ) {
i - -;
}
/* 返 回 0 则 说 明 查 找 失 败 */
return i;
}边栏推荐
- [advanced Android] kotlin delegate attribute
- Pyspark, paid for data cleaning and uploading to the database
- Two ways to improve the writing efficiency of hard disk storage data
- Weekly Postgres world news 2022w02
- [JS reverse hundreds of cases] the login of a HN service network is reverse, and the verification code is null and void
- 【LeetCode】23. Merge K ascending linked lists
- Using jhipster to build microservice architecture
- Section 2: spingboot unit test
- [machine learning] wuenda's machine learning assignment ex2 logistic regression matlab implementation
- 支持在 Kubernetes 运行,添加多种连接器,SeaTunnel 2.1.2 版本正式发布!
猜你喜欢

Static code block, code block, constructor execution order

Two ways to improve the writing efficiency of hard disk storage data

bubble sort

浅析2022年物联网现状
![[machine learning] wuenda's machine learning assignment ex2 logistic regression matlab implementation](/img/eb/0d4caf0babbe14f51f4dbf1b9ae65d.png)
[machine learning] wuenda's machine learning assignment ex2 logistic regression matlab implementation

What if the self incrementing IDs of online MySQL are exhausted?

Insérer le tri directement

Compilation, installation and global configuration section description of haproxy
![[OWT] OWT client native P2P E2E test vs2017 build 2: test unit construction and operation](/img/b0/4ea8069a88ce19ca7dbfa67ac9fcba.png)
[OWT] OWT client native P2P E2E test vs2017 build 2: test unit construction and operation

仿360桌面悬浮球插件
随机推荐
[tcapulusdb knowledge base] [list table] example code of batch deleting data at specified location in the list
在 KubeSphere 上部署 Apache Pulsar
How to implement collection sorting?
Gx3001q UI instructions for upgrading 8-bit color to 16 bit color
Swiftui component encyclopedia creating animated 3D card scrolling effects using Scrollview and geometryreader
Three ways to export excel from pages
mysql如何删除表的一行数据
What is the difference between comparator and comparable?
mysql,字段问题
What is the difference between ArrayList and array?
炫酷鼠标跟随动画js插件5种
SVG+JS智能家居监控网格布局
svg d3.js生成tree树状图
January 17, 2022: word rule II. Give you a pattern and a character
直接插入排序
高效的远程办公经验 | 社区征文
数据加密技术之源代码加密
AI 视频云 VS 窄带高清,谁是视频时代的宠儿
What is the APM tool skywalking
背景彩带动画插件ribbon.js