程序中有这样random和randomize头文件需要包含哪些?请指教
我的程序中有这样random和randomize头文件包含有:
#include<iomanip>
#include<cstdlib>
#include<iostream>
using namespace std;
但是总是出错:
'random' : undeclared identifier
'randomize' : undeclared identifier
请高手指点。我把完整程序也贴在下面:
#include<iomanip>
#include<cstdlib>
#include<iostream>
using namespace std;
template<class T>
int linsearch(T *v,int N, T key)
{
for(int i=0;i<N;i++)
{if (v[i]==key)return i;}
return -1;
}
inline int RandI(int N)
{
return random(N)+1;
}
int main()
{
int index;
int key=32;
randomize();
const int size=20;
int data[size];
for(int i=0;i<size;i++)
data[i]=RandI(85);
cout<<"\ndata's value are :"
<<endl;
for( i=0;i<size;i++)
{
cout<<setw(10)<<data[i];
if(i%5==4)cout<<endl;
}
index=linsearch(data,size,key);
if(index>-1)
cout<<key<<"is the "<<index+1
<<"th palce"<<endl;
else
cout<<"cannot find "<<key<<endl;
return 0;
}