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
This commit is contained in:
parent
2cf18a1ff3
commit
8a7aac7c23
385 changed files with 2 additions and 1468 deletions
41
2025.02.28/09Ex/solve.c
Normal file
41
2025.02.28/09Ex/solve.c
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include "solve.h"
|
||||
|
||||
void t9_solve(char **a, int n, int (*cmp)(const char *, const char *))
|
||||
{
|
||||
while (n > 1)
|
||||
{
|
||||
int is_edge = 0, ind_x = findIndex(a, n, a[n/2], cmp);
|
||||
if (ind_x < n-ind_x)
|
||||
{
|
||||
if (ind_x == 0) is_edge = 1;
|
||||
t9_solve(a, ind_x, cmp);
|
||||
a += ind_x + is_edge;
|
||||
n -= ind_x + is_edge;
|
||||
} else
|
||||
{
|
||||
t9_solve(a+ind_x, n-ind_x, cmp);
|
||||
n = ind_x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int findIndex(char **a, int n, char *x, int (*cmp)(const char *, const char *))
|
||||
{
|
||||
int i = 0, j = n-1;
|
||||
char *temp;
|
||||
|
||||
while (1)
|
||||
{
|
||||
for (; i < n; i++) if (cmp(a[i], x) >= 0) break;
|
||||
for (; j >= 0; j--) if (cmp(a[j], x) <= 0) break;
|
||||
|
||||
if (i >= j) break;
|
||||
temp = a[i];
|
||||
a[i] = a[j];
|
||||
a[j] = temp;
|
||||
|
||||
i++, j--;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue