This commit is contained in:
ada-dmitry
2023-05-09 17:52:40 +03:00
parent 875630a713
commit 8fb559981e
57 changed files with 0 additions and 794 deletions
+50
View File
@@ -0,0 +1,50 @@
#include "function.c"
int main() {
srand(time(0));
Node* l = malloc(sizeof(Node));
if (l == NULL)
exit(1);
int i, j;
for (i = 0; i < N; i++) {
char s[STR_LEN];
for (j = 0; j < STR_LEN - 1; j++)
s[j] = 'a' + rand() % 25;
s[j + 1] = '\0';
add_tail(l, rand() % 100, s);
}
printf("\nAfter add_tail(%d):\n", len(l));
linked_print(l);
l = add_head(l, 5, "head");
printf("\nAfter add_head(%d):\n", len(l));
linked_print(l);
l = del_head(l);
printf("\nAfter del_head(%d):\n", len(l));
linked_print(l);
swap(l, 0, 1);
printf("\nAfter swap first and second el:\n");
linked_print(l);
del_tail(l);
printf("\nAfter del_tail(%d):\n", len(l));
linked_print(l);
select_sort(l);
printf("\nAfter sort:\n");
linked_print(l);
printf("\nWriting to file test.txt\n");
list_fprintf(l, "test.txt");
printf("\nRead from file test.txt:\n");
Node* l2 = list_fscanf("test.txt");
linked_print(l2);
free(l);
return 0;
}