P24_1.CPP
资源名称:ds1-3.rar [点击查看]
上传用户:chaiyuqiu
上传日期:2022-08-03
资源大小:27k
文件大小:0k
源码类别:
数据结构
开发平台:
C/C++
- int SeqSearch ( int a[], const int n, const int x ) {
- int i = 0;
- while ( i < n && a[i] != x ) i++;
- if ( i == n ) return -1;
- return i;
- }
- #include <iostream.h>
- void main() {
- static int a[10] = {1,2,3,4,5,6,7,8,9,10};
- int i = SeqSearch ( a, 10, 6);
- cout << "The location is: " << i << endl;
- }