Added last three homeworks
This commit is contained in:
parent
f7b2367bc4
commit
0e3d948c9f
363 changed files with 18214 additions and 0 deletions
29
2025.02.21/4Ex/solve.c
Normal file
29
2025.02.21/4Ex/solve.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include "solve.h"
|
||||
|
||||
int t4_solve(char ** a, int n, char *s) {
|
||||
size_t len_s = strlen(s);
|
||||
int i, j, k;
|
||||
for (i = 0, j = 0, k = 0; i < n; ++i) {
|
||||
if (len_s <= strlen(a[i])) {
|
||||
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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue