+ 1

Linear search using function

A simple program to perform linear search in an sorted or unsorted array.

27th Jan 2017, 6:46 AM
Abdul Khan
2 Réponses
+ 2
Up I will write: template <class A> int search(A arr[], int size, A value) { /* Your statement */ }
30th Jan 2017, 9:50 PM
Wojciech Bruski
Wojciech Bruski - avatar
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); }
27th Jan 2017, 7:26 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar