#include
#include
#include
using namespace std;
template
int find(T A[].int D, T key)
{
for (int i = 0; i < D; i++)
{
if (A[i] == key)
return i;
}
return -1;
}
int main()
{
int a[30];
int index;
int key = 65;
int n = 100;
srand(time(0));
for (int i = 0; i < 30; i++)
{
a[i] = rand() % n + 1;
cout << "a[" << i << "]=" << a[i] << '\t';
}
cout << endl;
index = find(a,30,key);
if (index>-1)
cout << "在第" << index + 1 << "个元素的位置" << "查找到" << key << endl;
else
cout << "数据没有查找到" << endl;
}