2nd_Sem_Bogachev/2025.02.28/01Ex/solve.c
AZEN-SGG 8a7aac7c23 refactor(structure): normalize folder names with leading zeros for consistency
- Renamed all folders from format NEx (e.g., 1Ex, 2Ex...) to 0NEx (01Ex, 02Ex, etc.)
- Updated subdirectories and files accordingly
- Removed old main Makefile and tasks (a01.c–a09.c, solve.c, io_status.h), likely obsolete
- Cleaned up deprecated task binaries and configs
2025-03-23 21:14:20 +03:00

14 lines
332 B
C

#include "solve.h"
int t1_solve(char **a, int n, char *x, int (*cmp)(const char *, const char *)) {
int avg = (n + (-1)*(n%2)) / 2;
int comp;
if (n == 0) return 0;
comp = cmp(x, a[avg]);
if (comp < 0) return t1_solve(a, avg, x, cmp);
if (comp > 0) return avg+1 + t1_solve(a+avg+1, n-(avg+1), x, cmp);
else return avg;
}