#include<stdio.h> #include<stdlib.h> int main() { int data[] = { 1, 2, 3, 4, 5, 6, 7 },n=7; int low = 0, high = n - 1,mid = (low + high) / 2; int x; scanf_s("%d", &x); while (high>=low) { if (data[mid] == x) { printf("%d data[%d] %d ", data[mid],mid,x); break; } else if (data[mid] < x) { low = mid + 1; } else if (data[mid] > x) { high = mid - 1; } mid = (high + low) / 2; if (low > high) { printf("no in arr "); } } return 0; }