Added last three homeworks
This commit is contained in:
parent
f7b2367bc4
commit
0e3d948c9f
363 changed files with 18214 additions and 0 deletions
21
2025.02.28/3Ex/solve.c
Normal file
21
2025.02.28/3Ex/solve.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include "solve.h"
|
||||
|
||||
int t3_solve(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