Не знаю на сколько это правильно, но работает =) Спасибо.#include <stdio.h>
#define SIZE 10
int main (void) {
int arrayOne [SIZE], countOne, countTwo, reserve, search, left, right, mid;
for (countOne = 0; countOne < SIZE; countOne++) {
printf ("Enter array (%d): \t", SIZE - countOne);
scanf ("%d", &arrayOne [countOne]);
}
printf ("%s%10s \n", "Element", "Value");
for (countOne = 0; countOne < SIZE - 1; countOne++) {
for (countTwo = 0; countTwo < SIZE - countOne - 1; countTwo++) {
if (arrayOne [countTwo] > arrayOne [countTwo + 1]) {
reserve = arrayOne [countTwo];
arrayOne [countTwo] = arrayOne [countTwo + 1];
arrayOne [countTwo + 1] = reserve;
}
}
}
for (countOne = 0; countOne < SIZE; countOne++) {
printf ("%7d%10d \n", countOne, arrayOne [countOne]);
}
printf ("Enter value: \t");
scanf ("%d", &search);
left = 0;
right = SIZE - 1;
while (left < right) {
mid = (left + right) / 2;
if (search <= arrayOne [mid]) {
right = mid;
} else {
left = mid + 1;
}
}
if (search == arrayOne [right]) {
printf ("Ok! \n");
} else {
printf ("No! \n");
}
return 0;
}