/*
插值查找:数组是线性递增的,如果某次迭代处理的数组位于最左边元素A[L]和最右边元素A[R]之
间的一部分,沿着穿越点(L,A[L])和点(R,A[R])的直线分布的.
*/
#include<stdio.h>
int main()
{
int a[100],i,l,r,n,x,v;
printf("Please enter the len of the array:");
scanf("%d",&n);
printf("Please enter the array:");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
printf("Please enter the number value want to find:");
scanf("%d",&v);
l=0;
r=n-1;
do {
x=l+((v-a[l])*(r-l))/(a[r]-a[l]);
if(v<a[x])
r=x-1;
if(v>a[x])
l=x+1;
}while(v!=a[x]);
printf("The index of %d is:%d./n",v,x);
return 0;
}