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
44
2025.02.21/05Ex/solve.c
Normal file
44
2025.02.21/05Ex/solve.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include "solve.h"
|
||||
|
||||
int t5_solve(char ** a, int n, char *s) {
|
||||
int i, j, k;
|
||||
for (i = 0, j = 0, k = 0; i < n; ++i) {
|
||||
if (!check(a[i], s)) {
|
||||
if (i != j)
|
||||
{
|
||||
a[j] = a[i];
|
||||
}
|
||||
j++;
|
||||
k = 0;
|
||||
} else {
|
||||
if (k == 0) {
|
||||
if (i != j)
|
||||
a[j] = a[i];
|
||||
j++;
|
||||
} else {
|
||||
free(a[i]);
|
||||
}
|
||||
k++;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = j; i < n; ++i) a[i] = 0;
|
||||
|
||||
return j;
|
||||
}
|
||||
|
||||
|
||||
bool check(char *a, char *s) {
|
||||
int i;
|
||||
int len_s = (int)strlen(s);
|
||||
int len_a = (int)strlen(a);
|
||||
int diff = len_a - len_s;
|
||||
|
||||
if (diff < 0) return false;
|
||||
|
||||
for (i = (len_a - 1); i > (diff - 1); --i) {
|
||||
if (a[i] != s[i - diff]) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue