2019-04-19 22:44:06 C

C

Copy Copied! Full
int func1(int x){ int ok = 0;//解が存在する値 int ng = n;//解が存在しない値 int mid=0; while(abs(ok-ng)>1){ mid = (ok+ng)/2; if(x>a[mid]){ ok = mid; }else{ ng = mid; } } return mid; printf("mid = %d\n",mid); }