Added last three homeworks
This commit is contained in:
parent
f7b2367bc4
commit
0e3d948c9f
363 changed files with 18214 additions and 0 deletions
23
2025.02.28/3Ex/sort.c
Normal file
23
2025.02.28/3Ex/sort.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include "sort.h"
|
||||
|
||||
int up_strcmp(const char *a, const char *b)
|
||||
{ return strcmp(a, b); }
|
||||
|
||||
int down_strcmp(const char *a, const char *b)
|
||||
{ return -strcmp(a, b); }
|
||||
|
||||
int up_len(const char *a, const char *b)
|
||||
{
|
||||
int i = 0;
|
||||
while (1)
|
||||
{
|
||||
if (a[i] == '\0' && b[i] == '\0') return strcmp(a, b);
|
||||
else if (a[i] == '\0') return -1;
|
||||
else if (b[i] == '\0') return 1;
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
int down_len(const char *a, const char *b)
|
||||
{ return -up_len(a, b); }
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue