正在加载图片...
顶序表的搜索算法 template <class e> int Seqlist<E>: Search(e x)const 在表中顺序搜索与给定值ⅹ匹配的表项,找到则 ∥/函数返回该表项是第几个元素,否则函数返回0 for(nti=0;i<=last;i++)顺序搜索 if data1==x) return 1+1;/表项序号和表项位置差1 return o ∥搜索失败11 顺序表的搜索算法 template <class E> int SeqList<E>::Search(E & x) const { //在表中顺序搜索与给定值 x 匹配的表项,找到则 //函数返回该表项是第几个元素,否则函数返回0 for (int i = 0; i <= last; i++) //顺序搜索 if ( data[i] == x ) return i+1; //表项序号和表项位置差1 return 0; //搜索失败 };
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有