标签:std i++ amp else bsp scan lse nbsp turn
//折半查找 # include<stdio.h> int a[15]; int n; int f=0,r=14; int main() { printf("请输入数组:"); for(int i =0;i<15;i++) scanf("%d",&a[i]); printf("请输入n:"); scanf("%d",&n); while(f<=r) { int temp=(f+r)/2; if(a[temp]==n) { printf("%d",temp); return 0; } else if(a[temp]<n) f=temp+1; else r=temp-1; } printf("无此数\n"); return 0; }
标签:std i++ amp else bsp scan lse nbsp turn
原文地址:https://www.cnblogs.com/bboykaku/p/12426270.html