[原创]请大家看看这个程序
#include “stdio.h“int binsort(int key,int list[],int min,int max) {
int middle = (min+max)/2;
if(min <= max) {
if(key == list[middle]) {
return middle;
}
else if(key < list[middle]) {
max = middle -1 ;
binsort(key,list,min,max);
}
else {
min = middle +1;
binsort(key,list,min,max);
}
}
else
return (-1);
}
int main(void)
{
int list[6] ={1,2,3,4,6,7};
int i = binsort(9,list,0,5);
printf(“%d“,i);
}
不知道为什么分别在gcc和cl编译器下得到的结果不一样
cl下得到的是正确的结果-1,而gcc下却是1627407856