![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<stdio.h> int f(int a[],int low,int high,int x) { int mid; while (low<=high) { mid=(low+high)/2; if(a[mid]>x) high=mid-1; else if(a[mid]<x) low=mid+1; else return mid+1; } return 0; } int main() { int a[30],n,i,x,y; while(scanf("%d",&n)!=EOF) { for(i=0;i<=n;i++) scanf("%d",&a[i]); x=a[n]; y=f(a,0,n,x); if ( y==0 ) printf("No found! "); else printf("%d ",y); } return 0; }
#include<stdio.h>
int f(int a[],int low,int high,int x)
{ int mid;
while (low<=high)
{
mid=(low+high)/2;
if(a[mid]>x) high=mid-1;
else if(a[mid]<x) low=mid+1;
else return mid+1;
}
return 0;
}
int main()
{
int a[30],n,i,x,y;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<=n;i++)
scanf("%d",&a[i]);
x=a[n];
y=f(a,0,n,x);
if ( y==0 ) printf("No found!
");
else printf("%d
",y);
}
return 0;
}
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<stdio.h> int a[30],x; int f(int low,int high) { int mid; while (low<=high) { mid=(low+high)/2; if(a[mid]>x) high=mid-1; else if(a[mid]<x) low=mid+1; else return mid; } return -1; } int main() { int n,i,y; while(scanf("%d",&n)!=EOF) { for(i=0;i<=n;i++) scanf("%d",&a[i]); x=a[n]; y=f(0,n-1); if ( y==-1 ) printf("No found! "); else printf("%d ",y+1); } return 0; }
#include<stdio.h>
int a[30],x;
int f(int low,int high)
{ int mid;
while (low<=high)
{
mid=(low+high)/2;
if(a[mid]>x) high=mid-1;
else if(a[mid]<x) low=mid+1;
else return mid;
}
return -1;
}
int main()
{
int n,i,y;
while(scanf("%d",&n)!=EOF)
{ for(i=0;i<=n;i++)
scanf("%d",&a[i]);
x=a[n];
y=f(0,n-1);
if ( y==-1 ) printf("No found!
");
else printf("%d
",y+1);
}
return 0;
}
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<stdio.h> int f(int a[],int low,int high,int x) { int mid; while (low<=high) { mid=(low+high)/2; if(a[mid]>x) high=mid-1; else if(a[mid]<x) low=mid+1; else return mid; } return -1; } int main() { int a[30],n,i,x,y; while(scanf("%d",&n)!=EOF) { for(i=0;i<=n;i++) scanf("%d",&a[i]); x=a[n]; y=f(a,0,n,x); if ( y==-1 ) printf("No found! "); else printf("%d ",y+1); } return 0; }
#include<stdio.h>
int f(int a[],int low,int high,int x)
{ int mid;
while (low<=high)
{
mid=(low+high)/2;
if(a[mid]>x) high=mid-1;
else if(a[mid]<x) low=mid+1;
else return mid;
}
return -1;
}
int main()
{
int a[30],n,i,x,y;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<=n;i++)
scanf("%d",&a[i]);
x=a[n];
y=f(a,0,n,x);
if ( y==-1 ) printf("No found!
");
else printf("%d
",y+1);
}
return 0;
}
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<stdio.h> int f(int a[],int low,int high,int x) { int mid; while (low<=high) { mid=(low+high)/2; if(a[mid]>x) high=mid-1; else if(a[mid]<x) low=mid+1; else return mid+1; } return -1; } int main() { int a[30],n,i,x,y; while(scanf("%d",&n)!=EOF) { for(i=0;i<=n;i++) scanf("%d",&a[i]); x=a[n]; y=f(a,0,n,x); if ( y==-1 ) printf("No found! "); else printf("%d ",y); } return 0; }
#include<stdio.h>
int f(int a[],int low,int high,int x)
{ int mid;
while (low<=high)
{
mid=(low+high)/2;
if(a[mid]>x) high=mid-1;
else if(a[mid]<x) low=mid+1;
else return mid+1;
}
return -1;
}
int main()
{
int a[30],n,i,x,y;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<=n;i++)
scanf("%d",&a[i]);
x=a[n];
y=f(a,0,n,x);
if ( y==-1 ) printf("No found!
");
else printf("%d
",y);
}
return 0;
}