#include<iostream>
#include<Windows.h>
using namespace std;
typedef int ElemType;
/*___________________________________________________________________________________________________________
文件说明:
【顺序查找算法】
基本说明:
【顺序查找】:又称为线性查找,主要用在---线性表---中进行查找
【顺序查找】通常分为:1---无序线性表的一般查找;2---对关键字有序的顺序表查找
优缺点分析:
【1】【顺序查找的缺点】:当线性表的表长过于长时,平均查找长度较大,效率低。
【2】【顺序查找的优点】:对顺序表中数据元素的【存储】没有要求,【顺序存储】和【链式存储】均可。
【3】需注意:对于线性表的【链式存储】只能使用【顺序查找】
____________________________________________________________________________________________________________*/
template<typename ElemType>ElemType SeqSearch(ElemType array[],ElemType key,int iLength)
{
for(int index=0;index<iLength;index++)
{
if(array[index]==key)
{
return index;
}
}
return -1;
}
/*______________________________________________________________________________________