//顺序查找
#include <stdio.h>
#include <stdlib.h>
typedef struct{ //查找表的数据结构
int *elem; //元素存储空间基址,建表时按实际长度分配,0号单元留空
int length; //表长
}SSTable;
int i;
int search(SSTable ST,int key){
ST.elem[0]=key; //哨兵(表中无key时,return i=0)
for(i=ST.length;ST.elem[i]!=key;i--); //从后往前找
return i;
}
数据结构——线性表的顺序查找
最新推荐文章于 2023-12-22 16:58:24 发布