64,637
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <cstddef>
using namespace std;
int * find(int *p,const int &length,const int &value)
{
for(int i=0;i<length;++i)
{
if(p[i]==value)
{
return &p[i];
}
}
return NULL;
}
int main()
{
const size_t size=10;
int arr[size]={0};
int *p=find(arr,size,0);
if(p==NULL)
{
cout<<"Can't find the specified value in this array"<<endl;
}
else
{
cout<<p<<endl;
}
return 0;
}