C++大学教程上面的一个题目,关于搜索关键字的。VC6.0中编译通过,链接文件的时候出了问题,请指教程序的问题。
#include <iostream>
using namespace std;
int linearSearch( const int [], int, int );
int main()
{
const int arraySize = 100;
int a[ arraySize ], searchKey, element;
for(int x = 0; x < arraySize; x++ ) // create some data
a[x] = 2*x;
cout << "Enter integer search key:" << endl;
cin >> searchKey;
element = linearSearch( a, searchKey, arraySize );
if ( element != -1 )
cout << "Found value in element " << element << endl;
else
cout << "Value not found" << endl;
return 0;
}
int linearsearch( const int arraay[], int key, int sizeofArray )
{
for (int n = 0; n < sizeofArray; n++ )
if( arraay[ n ] == key )
return n;
return -1;
}