#include <iostream>
#include <cstdio>
using namespace std;
#define siz 100
int a[siz];
bool linear_search(int a[], int n, int s){
if(n<0) return false;
if(a[n] == s) return true;
linear_search(a,n-1,s);
}
int main()
{
int n;
//freopen("input.txt", "r", stdin);
while(cin>>n){
for(int i=0;i<n;i++){
cin>>a[i];
}
if(linear_search(a,n-1,43)) puts("Found");
else puts("Not Found");
}
return 0;
}
Saturday, August 17, 2013
Linear Search using Recursion.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment