数组查找
#include<stdio.h>int linearSearch (int [], int, int);
main()
{
int a[5]={1, 2, 3, 4, 6};
int b, size=5, key;
scanf("%d", &key);
b=linearSearch(a, key, size);
if(b!=-1)
printf("Found the number is %d\n", b);
else
printf("Not found the number\n");
system("pause");
}
int linearSearch (int x[], int n, int y)
{
if(y>0) /*被调用函数怎么实现数组查找的???????
{ 和递归有关系吗????*/
if(x[y-1]==n)
return y-1;
else
linearSearch(x, n, y-1);
}
else
return -1;
}