+ 1
Linear search using function
A simple program to perform linear search in an sorted or unsorted array.
2 Antworten
+ 2
Up
I will write:
template <class A>
int search(A arr[], int size, A value)
{ /* Your statement */ }
0
int search(int array[],int size,int value){
//work with other array types
int i=0;
while(i<size && array[i]!=value){
++i;
}
return (i==size?-1:i);
}