#include"stdio.h"
struct a {int x; int n; } main() { int t,t1; struct a a[11];
struct a *low,*high,*mid; int key; printf("请输入要查询的数字:\n"); scanf("key is %d",&key); a[0].x=0;a[0].n=0; *low=a[1]; *high=a[10]; t=((*low).n+(*high).n)/2; *mid=a[t]; for(t1=1;t1<=10;t1++) {printf("请从小到大输入10个数字:\n"); scanf("%d",&a[t1].x); } for(t1=1;t1<=10;t1++) {a[t1].n=t1; /*printf("%d",a[t1].n); */ }
loop:if((*mid).x==key) /*!!!!!!注意!!!!!*/ {printf("查询到的数字为:%d,该数字在数组的第%d号",mid->x,mid->n); } if(mid->x>key) {*high=a[t-1]; t=(low->n+high->n)/2; *mid=a[t]; if((low->x==mid->x)&&(low->n==mid->n)) lo{ if(low->x==key) {printf("查询到的数字为:%d,该数字在数组的第%d号",low->x,low->n); }/*3号!!!!!*/ if(high->x==key) {printf("查询到的数字为:%d,该数字在数组的第%d号",high->x,high->n); } printf("数据没有找到!!");
} /* ?????!!!!!!潜在的问题... */
goto loop; } if(mid->x<key) {*low=a[t+1]; t=((low->n)+(high->n))/2; *mid=a[t]; if((mid->x==high->x)&&(mid->n==high->n)) {goto loo;} /*注意!!!*/ goto loop;
}
}