From 3045489a7d37c537f1200ac0bd2742721b762a54 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 1 Oct 2024 14:01:13 +0200 Subject: [PATCH 001/151] Initializacia --- cv1/program.c | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 cv1/program.c diff --git a/cv1/program.c b/cv1/program.c new file mode 100644 index 0000000..4f791d9 --- /dev/null +++ b/cv1/program.c @@ -0,0 +1,5 @@ +#include +int main() { + return 0; +} + From f314b8479f673298e63a1bf8a7fb7bbfa9ef72be Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 1 Oct 2024 15:22:17 +0200 Subject: [PATCH 002/151] Initializacia --- cv2/program.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 cv2/program.c diff --git a/cv2/program.c b/cv2/program.c new file mode 100644 index 0000000..93d2060 --- /dev/null +++ b/cv2/program.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include + +#define LINE_SIZE 100 +#define LIST_SIZE 100 + +struct pizza{ + char name[LINE_SIZE]; + float price; +} + +int read_pizza_list(struct pizza* list){ + char buffer[LINE_SIZE] + while(fgets(buffer, LINE_SIZT, stdin) == 0){ + + } +} + +int read_item(struct pizza *item) { + static int currentIndex = 0; + + if (currentIndex >= sizeof(menu) / sizeof(menu[0])) { + return 0; + } + + memcpy(item, &menu[currentIndex], sizeof(struct pizza)); + currentIndex++; + + return 1; +} + + +int main(){ + struct pizza vacerajsia = {.name = "Vajcova pizza", .price = 0.2}; + printf("Pizza: %s, cena: %f/n", vacerajsia.name, vacerajsia.price -0.1); + + // Prechadzajte vsetky miesta jedalneho listka + int counter = 0; + for (int i=0; i< LIST_SIZE; i++){ + struct pizza item; + memset(&item,0,sizeof(struct pizza)); + // Nacitajte polozku do pomocnej premennej + // Na nacitanie pouzite vlastny kod + int r = read_item(&item); + if (r){ + // Ak sa nacitanie podarilo, skopirujte polozku do pola + memcpy(&listok[i],&item,sizeof(struct pizza)); + // Spocitame uspesne nacitane polozky + counter += 1; + } + else{ + // Ak sa nacitanie nepodarilo, nasli sme poslednu polozku + // Prerusim nacitanie + break; + } + } + // Na konci budemem mat nacitany jedalny listok + // V premennej counter je pocet uspesne nacitanych poloziek + return 0; +} + + From 3cbf4047a2a246a77149486a8b5889aaee382f03 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 1 Oct 2024 15:31:23 +0200 Subject: [PATCH 003/151] initializacia --- cv2/program.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/cv2/program.c b/cv2/program.c index 93d2060..2e9c03d 100644 --- a/cv2/program.c +++ b/cv2/program.c @@ -18,17 +18,8 @@ int read_pizza_list(struct pizza* list){ } } -int read_item(struct pizza *item) { - static int currentIndex = 0; +int read_item(struct pizza* list) { - if (currentIndex >= sizeof(menu) / sizeof(menu[0])) { - return 0; - } - - memcpy(item, &menu[currentIndex], sizeof(struct pizza)); - currentIndex++; - - return 1; } From c2c30fbd59e2c1874d42e6aedb293405ccdf9f3f Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 12:27:38 +0000 Subject: [PATCH 004/151] Initializacia --- cv1/program.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 2 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 4f791d9..556d861 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -1,5 +1,105 @@ #include -int main() { - return 0; +#include +#include +#include + +#define LINESIZE 100 +#define MENU_SiZE 100 + +// Štruktúra pre položku jedálneho lístka +struct pizza{ + char name[LINESIZE]; + float price; } +// Prepisovací algoritmus pre "Hack3r scr1pt" +char hacker_script(char l){ + switch(tolower(char l)){ + case 'o': return '0'; + case 'i': return '1'; + case 'z': return '2'; + case 'e': return '3'; + case 'a': return '4'; + case 's': return '5'; + case 'b': return '6'; + case 't': return '7'; + case 'q': return '9'; + default: return tolower(c); + } +} + +// Function to transform a string into "Hack3r scr1pt" +void transform_to_hacker_script(const char *src, char *dest) { + while (*src) { + *dest++ = hacker_script(*src++); + } + *dest = '\0'; +} + +// Function to search for a normalized string in the name +int contains_normalized(const char *name, const char *search) { + char transformed_name[LINESIZE], transformed_search[LINESIZE]; + + // Transform both strings + transform_to_hacker_script(name, transformed_name); + transform_to_hacker_script(search, transformed_search); + + // Search for the string in the name + return strstr(transformed_name, transformed_search) != NULL; +} + +// Function to read a single menu item +int read_pizza(struct pizza *item) { + char line[LINESIZE]; + + // Read the name + if (!fgets(item->name, LINESIZE, stdin)) { + return 0; // End of input + } + + // Remove newline character + item->name[strcspn(item->name, "\n")] = '\0'; + + // Read the price + if (!fgets(line, LINESIZE, stdin)) { + return 0; // Failed to read price + } + + // Convert string to float + item->price = strtof(line, NULL); + return 1; // Successfully read +} + +int main() { + struct pizza menu[MENU_SIZE]; + char search[LINESIZE]; + int count = 0; + + // Read the search string + printf("Zadaj hladanu surovinu:\n"); + fgets(search, LINESIZE, stdin); + search[strcspn(search, "\n")] = '\0'; // Remove newline + + printf("Zadaj jedalny listok:\n"); + + // Read the menu items + while (read_pizza(&menu[count])) { + count++; + } + + printf("\nVysledky vyhladavania:\n"); + + // Search and print items that match the search string + int found_count = 0; + for (int i = 0; i < count; i++) { + if (contains_normalized(menu[i].name, search)) { + printf("%s\n%.2f\n", menu[i].name, menu[i].price); + found_count++; + } + } + + // Print the total number of loaded items + printf("Nacitanych %d poloziek.\n", count);s + + return 0; +} From 831b080f14bdb7ef30ce23711048f3e0ca852240 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 12:28:51 +0000 Subject: [PATCH 005/151] Initializacia --- cv1/program.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 556d861..f740b98 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -6,13 +6,11 @@ #define LINESIZE 100 #define MENU_SiZE 100 -// Štruktúra pre položku jedálneho lístka struct pizza{ char name[LINESIZE]; float price; } -// Prepisovací algoritmus pre "Hack3r scr1pt" char hacker_script(char l){ switch(tolower(char l)){ case 'o': return '0'; @@ -28,7 +26,6 @@ char hacker_script(char l){ } } -// Function to transform a string into "Hack3r scr1pt" void transform_to_hacker_script(const char *src, char *dest) { while (*src) { *dest++ = hacker_script(*src++); @@ -36,38 +33,30 @@ void transform_to_hacker_script(const char *src, char *dest) { *dest = '\0'; } -// Function to search for a normalized string in the name int contains_normalized(const char *name, const char *search) { char transformed_name[LINESIZE], transformed_search[LINESIZE]; - - // Transform both strings + transform_to_hacker_script(name, transformed_name); transform_to_hacker_script(search, transformed_search); - // Search for the string in the name return strstr(transformed_name, transformed_search) != NULL; } -// Function to read a single menu item int read_pizza(struct pizza *item) { char line[LINESIZE]; - // Read the name if (!fgets(item->name, LINESIZE, stdin)) { - return 0; // End of input + return 0; } - // Remove newline character item->name[strcspn(item->name, "\n")] = '\0'; - // Read the price if (!fgets(line, LINESIZE, stdin)) { - return 0; // Failed to read price + return 0; } - // Convert string to float item->price = strtof(line, NULL); - return 1; // Successfully read + return 1; } int main() { @@ -75,21 +64,18 @@ int main() { char search[LINESIZE]; int count = 0; - // Read the search string printf("Zadaj hladanu surovinu:\n"); fgets(search, LINESIZE, stdin); - search[strcspn(search, "\n")] = '\0'; // Remove newline + search[strcspn(search, "\n")] = '\0'; printf("Zadaj jedalny listok:\n"); - // Read the menu items while (read_pizza(&menu[count])) { count++; } printf("\nVysledky vyhladavania:\n"); - // Search and print items that match the search string int found_count = 0; for (int i = 0; i < count; i++) { if (contains_normalized(menu[i].name, search)) { @@ -97,8 +83,7 @@ int main() { found_count++; } } - - // Print the total number of loaded items + printf("Nacitanych %d poloziek.\n", count);s return 0; From d0d1dc242097e11967c18bd7f847bd684638e487 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 12:33:13 +0000 Subject: [PATCH 006/151] Initializacia --- cv1/program.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index f740b98..601e9d4 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -4,15 +4,15 @@ #include #define LINESIZE 100 -#define MENU_SiZE 100 +#define MENU_SIZE 100 -struct pizza{ +struct pizza { char name[LINESIZE]; float price; -} +}; -char hacker_script(char l){ - switch(tolower(char l)){ +char hacker_script(char l) { + switch (tolower(l)) { case 'o': return '0'; case 'i': return '1'; case 'z': return '2'; @@ -22,7 +22,7 @@ char hacker_script(char l){ case 'b': return '6'; case 't': return '7'; case 'q': return '9'; - default: return tolower(c); + default: return tolower(l); } } @@ -48,7 +48,6 @@ int read_pizza(struct pizza *item) { if (!fgets(item->name, LINESIZE, stdin)) { return 0; } - item->name[strcspn(item->name, "\n")] = '\0'; if (!fgets(line, LINESIZE, stdin)) { @@ -65,8 +64,9 @@ int main() { int count = 0; printf("Zadaj hladanu surovinu:\n"); + fgets(search, LINESIZE, stdin); - search[strcspn(search, "\n")] = '\0'; + search[strcspn(search, "\n")] = '\0'; printf("Zadaj jedalny listok:\n"); @@ -83,8 +83,8 @@ int main() { found_count++; } } - - printf("Nacitanych %d poloziek.\n", count);s + + printf("Nacitanych %d poloziek.\n", count); return 0; } From 2eb10876da7fe90368e3e647ba6d4979097c0719 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 16:57:36 +0000 Subject: [PATCH 007/151] Initializacia --- cv1/program.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 601e9d4..c3fca68 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -64,18 +64,15 @@ int main() { int count = 0; printf("Zadaj hladanu surovinu:\n"); - fgets(search, LINESIZE, stdin); search[strcspn(search, "\n")] = '\0'; printf("Zadaj jedalny listok:\n"); - while (read_pizza(&menu[count])) { count++; } printf("\nVysledky vyhladavania:\n"); - int found_count = 0; for (int i = 0; i < count; i++) { if (contains_normalized(menu[i].name, search)) { From 127fb512251d5d4bafc620165dfb691ff0649205 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 16:59:35 +0000 Subject: [PATCH 008/151] Initializacia --- cv1/program.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cv1/program.c b/cv1/program.c index c3fca68..4a2305f 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -81,6 +81,10 @@ int main() { } } + if (found_count == 0) { + printf("\n"); + } + printf("Nacitanych %d poloziek.\n", count); return 0; From 969442f6e7ffc915346ee316d7845dfe12e655c6 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 17:03:28 +0000 Subject: [PATCH 009/151] Initializacia --- cv1/program.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cv1/program.c b/cv1/program.c index 4a2305f..be31ec9 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -67,6 +67,10 @@ int main() { fgets(search, LINESIZE, stdin); search[strcspn(search, "\n")] = '\0'; + for (int i = 0; search[i]; i++) { + search[i] = tolower(search[i]); + } + printf("Zadaj jedalny listok:\n"); while (read_pizza(&menu[count])) { count++; From f7276b6c986bde2f8218aceebab3a9b7767ad463 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 17:06:57 +0000 Subject: [PATCH 010/151] Initializacia --- cv1/program.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cv1/program.c b/cv1/program.c index be31ec9..69dddbf 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -54,7 +54,12 @@ int read_pizza(struct pizza *item) { return 0; } - item->price = strtof(line, NULL); + char *endptr; + item->price = strtof(line, &endptr); + if (endptr == line || *endptr != '\n') { + return 0; + } + return 1; } From 9732f585438c81c1a95b74080ac55e1810e344d3 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 17:11:25 +0000 Subject: [PATCH 011/151] Initializacia --- cv1/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv1/program.c b/cv1/program.c index 69dddbf..db2dd66 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -39,7 +39,7 @@ int contains_normalized(const char *name, const char *search) { transform_to_hacker_script(name, transformed_name); transform_to_hacker_script(search, transformed_search); - return strstr(transformed_name, transformed_search) != NULL; + return strcasestr(transformed_name, transformed_search) != NULL; } int read_pizza(struct pizza *item) { From eccfb157bf7cb81507e70c6c9fd3b538a6f65c53 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 17:14:16 +0000 Subject: [PATCH 012/151] Initializacia --- cv1/program.c | 1 - 1 file changed, 1 deletion(-) diff --git a/cv1/program.c b/cv1/program.c index db2dd66..6cf9a27 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -81,7 +81,6 @@ int main() { count++; } - printf("\nVysledky vyhladavania:\n"); int found_count = 0; for (int i = 0; i < count; i++) { if (contains_normalized(menu[i].name, search)) { From b5fbf7414eec2c02a46c57824df27d6da029a043 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 17:27:29 +0000 Subject: [PATCH 013/151] Initializacia --- cv1/program.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cv1/program.c b/cv1/program.c index 6cf9a27..86ab3b1 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -28,7 +28,12 @@ char hacker_script(char l) { void transform_to_hacker_script(const char *src, char *dest) { while (*src) { - *dest++ = hacker_script(*src++); + if (isupper(*src)) { + *dest++ = tolower(*src); + } else { + *dest++ = hacker_script(*src); + } + src++; } *dest = '\0'; } From 4f08259a05ef5c32adca28dcd4295f51529dc48d Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 17:32:07 +0000 Subject: [PATCH 014/151] Initializacia --- cv1/program.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 86ab3b1..2240865 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -94,8 +94,13 @@ int main() { } } - if (found_count == 0) { - printf("\n"); + if (found_count > 0) { + for (int i = 0; i < count; i++) { + if (contains_normalized(menu[i].name, search)) { + printf("%s\n%.2f\n", menu[i].name, menu[i].price); + found_count++; + } + } } printf("Nacitanych %d poloziek.\n", count); From 43922459dc795f137ec4cd7cd241795275bccb90 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 17:33:56 +0000 Subject: [PATCH 015/151] Initializacia --- cv1/program.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 2240865..b45f7ef 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -87,14 +87,8 @@ int main() { } int found_count = 0; - for (int i = 0; i < count; i++) { - if (contains_normalized(menu[i].name, search)) { - printf("%s\n%.2f\n", menu[i].name, menu[i].price); - found_count++; - } - } - if (found_count > 0) { + printf("\nVysledky vyhladavania:\n"); for (int i = 0; i < count; i++) { if (contains_normalized(menu[i].name, search)) { printf("%s\n%.2f\n", menu[i].name, menu[i].price); From b944c638ad18aec1b8ee52ce53610e53ed487525 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 17:38:24 +0000 Subject: [PATCH 016/151] Initializacia --- cv1/program.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index b45f7ef..59381f4 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -87,13 +87,13 @@ int main() { } int found_count = 0; - if (found_count > 0) { - printf("\nVysledky vyhladavania:\n"); - for (int i = 0; i < count; i++) { - if (contains_normalized(menu[i].name, search)) { - printf("%s\n%.2f\n", menu[i].name, menu[i].price); - found_count++; + for (int i = 0; i < count; i++) { + if (contains_normalized(menu[i].name, search)) { + if (found_count == 0) { + printf("\nVysledky vyhladavania:\n"); } + printf("%s\n%.2f\n", menu[i].name, menu[i].price); + found_count++; } } From d447a22ab1829c91ae6d074da63c9587c5eb9f23 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 17:59:06 +0000 Subject: [PATCH 017/151] Initializacia --- cv1/program.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 59381f4..ce7f787 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -28,12 +28,7 @@ char hacker_script(char l) { void transform_to_hacker_script(const char *src, char *dest) { while (*src) { - if (isupper(*src)) { - *dest++ = tolower(*src); - } else { - *dest++ = hacker_script(*src); - } - src++; + *dest++ = hacker_script(*src++); } *dest = '\0'; } @@ -44,7 +39,7 @@ int contains_normalized(const char *name, const char *search) { transform_to_hacker_script(name, transformed_name); transform_to_hacker_script(search, transformed_search); - return strcasestr(transformed_name, transformed_search) != NULL; + return strstr(transformed_name, transformed_search) != NULL; } int read_pizza(struct pizza *item) { @@ -59,12 +54,7 @@ int read_pizza(struct pizza *item) { return 0; } - char *endptr; - item->price = strtof(line, &endptr); - if (endptr == line || *endptr != '\n') { - return 0; - } - + item->price = strtof(line, NULL); return 1; } @@ -77,10 +67,6 @@ int main() { fgets(search, LINESIZE, stdin); search[strcspn(search, "\n")] = '\0'; - for (int i = 0; search[i]; i++) { - search[i] = tolower(search[i]); - } - printf("Zadaj jedalny listok:\n"); while (read_pizza(&menu[count])) { count++; @@ -89,9 +75,6 @@ int main() { int found_count = 0; for (int i = 0; i < count; i++) { if (contains_normalized(menu[i].name, search)) { - if (found_count == 0) { - printf("\nVysledky vyhladavania:\n"); - } printf("%s\n%.2f\n", menu[i].name, menu[i].price); found_count++; } From ba3d6439c03817829a7f1878f9f8fc3e5a11703d Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 18:09:27 +0000 Subject: [PATCH 018/151] Initializacia --- cv1/program.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cv1/program.c b/cv1/program.c index ce7f787..5ce3fb2 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -75,6 +75,9 @@ int main() { int found_count = 0; for (int i = 0; i < count; i++) { if (contains_normalized(menu[i].name, search)) { + if (found_count == 0) { + printf("\nVysledky vyhladavania:\n"); + } printf("%s\n%.2f\n", menu[i].name, menu[i].price); found_count++; } From 05d60af8c23c50c99fec12866b7e4ac0aa52230f Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 18:13:40 +0000 Subject: [PATCH 019/151] Initializacia --- cv1/program.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 5ce3fb2..ce7f787 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -75,9 +75,6 @@ int main() { int found_count = 0; for (int i = 0; i < count; i++) { if (contains_normalized(menu[i].name, search)) { - if (found_count == 0) { - printf("\nVysledky vyhladavania:\n"); - } printf("%s\n%.2f\n", menu[i].name, menu[i].price); found_count++; } From 6a822d93c1efe79948fb4dfca383cb2ffb135fe4 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 18:20:27 +0000 Subject: [PATCH 020/151] Initializacia --- cv1/program.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index ce7f787..24bb1b2 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -64,11 +64,14 @@ int main() { int count = 0; printf("Zadaj hladanu surovinu:\n"); - fgets(search, LINESIZE, stdin); + if (!fgets(search, LINESIZE, stdin)) { + printf("Error reading input.\n"); + return 1; + } search[strcspn(search, "\n")] = '\0'; printf("Zadaj jedalny listok:\n"); - while (read_pizza(&menu[count])) { + while (count < MENU_SIZE && read_pizza(&menu[count])) { count++; } From 839307eea030aa0a1a33e261d9410b29fe09eff9 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 18:22:55 +0000 Subject: [PATCH 021/151] Initializacia --- cv1/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv1/program.c b/cv1/program.c index 24bb1b2..808cbc2 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -76,7 +76,7 @@ int main() { } int found_count = 0; - for (int i = 0; i < count; i++) { + for (int i = 0; i < 3; i++) { if (contains_normalized(menu[i].name, search)) { printf("%s\n%.2f\n", menu[i].name, menu[i].price); found_count++; From df6e7666dc2d8e5a8c80fedf87b268a5f0d299a3 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 18:26:34 +0000 Subject: [PATCH 022/151] Initializacia --- cv1/program.c | 124 +++++++++++++++++++++----------------------------- 1 file changed, 52 insertions(+), 72 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 808cbc2..c6af434 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -1,89 +1,69 @@ #include -#include -#include #include +#include -#define LINESIZE 100 -#define MENU_SIZE 100 +#define MAX_INPUT_LENGTH 100 -struct pizza { - char name[LINESIZE]; - float price; +// Define the "Hack3r scr1pt" mapping +char hack3r_script_mapping[][2] = { + {'0', 'o'}, + {'1', 'i'}, + {'2', 'z'}, + {'3', 'e'}, + {'4', 'a'}, + {'5', 's'}, + {'6', 'b'}, + {'7', 't'}, + {'8', 'b'}, + {'9', 'q'} }; -char hacker_script(char l) { - switch (tolower(l)) { - case 'o': return '0'; - case 'i': return '1'; - case 'z': return '2'; - case 'e': return '3'; - case 'a': return '4'; - case 's': return '5'; - case 'b': return '6'; - case 't': return '7'; - case 'q': return '9'; - default: return tolower(l); - } -} - -void transform_to_hacker_script(const char *src, char *dest) { - while (*src) { - *dest++ = hacker_script(*src++); - } - *dest = '\0'; -} - -int contains_normalized(const char *name, const char *search) { - char transformed_name[LINESIZE], transformed_search[LINESIZE]; - - transform_to_hacker_script(name, transformed_name); - transform_to_hacker_script(search, transformed_search); - - return strstr(transformed_name, transformed_search) != NULL; -} - -int read_pizza(struct pizza *item) { - char line[LINESIZE]; - - if (!fgets(item->name, LINESIZE, stdin)) { - return 0; - } - item->name[strcspn(item->name, "\n")] = '\0'; - - if (!fgets(line, LINESIZE, stdin)) { - return 0; - } - - item->price = strtof(line, NULL); - return 1; -} - int main() { - struct pizza menu[MENU_SIZE]; - char search[LINESIZE]; + char ingredient[MAX_INPUT_LENGTH]; + char menu_item[MAX_INPUT_LENGTH]; int count = 0; - printf("Zadaj hladanu surovinu:\n"); - if (!fgets(search, LINESIZE, stdin)) { - printf("Error reading input.\n"); - return 1; - } - search[strcspn(search, "\n")] = '\0'; + // Read the ingredient to be searched + printf("Zadaj hladanu surovinu: "); + fgets(ingredient, MAX_INPUT_LENGTH, stdin); + ingredient[strcspn(ingredient, "\n")] = 0; // Remove newline character - printf("Zadaj jedalny listok:\n"); - while (count < MENU_SIZE && read_pizza(&menu[count])) { - count++; - } + // Read the menu items + while (1) { + printf("Zadaj jedalny listok: "); + fgets(menu_item, MAX_INPUT_LENGTH, stdin); + if (feof(stdin) || strlen(menu_item) == 1) { + break; + } + menu_item[strcspn(menu_item, "\n")] = 0; // Remove newline character - int found_count = 0; - for (int i = 0; i < 3; i++) { - if (contains_normalized(menu[i].name, search)) { - printf("%s\n%.2f\n", menu[i].name, menu[i].price); - found_count++; + // Apply the "Hack3r scr1pt" mapping to the name + char name_hack3r[MAX_INPUT_LENGTH]; + int j = 0; + for (int i = 0; menu_item[i]; i++) { + int found = 0; + for (int k = 0; k < 10; k++) { + if (menu_item[i] == hack3r_script_mapping[k][0]) { + name_hack3r[j++] = hack3r_script_mapping[k][1]; + found = 1; + break; + } + } + if (!found) { + name_hack3r[j++] = tolower(menu_item[i]); + } + } + name_hack3r[j] = 0; + + // Search for the ingredient in the name + if (strstr(name_hack3r, ingredient) != NULL) { + printf("%s\n", menu_item); + count++; } } + // Display the count of successful searches printf("Nacitanych %d poloziek.\n", count); return 0; -} +} \ No newline at end of file From ec266a099f68d60430b569acfe88647eeff5f05c Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 18:31:47 +0000 Subject: [PATCH 023/151] Initializacia --- cv1/program.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cv1/program.c b/cv1/program.c index c6af434..380dfcc 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -28,9 +28,10 @@ int main() { fgets(ingredient, MAX_INPUT_LENGTH, stdin); ingredient[strcspn(ingredient, "\n")] = 0; // Remove newline character + printf("Zadaj jedalny listok:\n"); // Print the prompt + // Read the menu items while (1) { - printf("Zadaj jedalny listok: "); fgets(menu_item, MAX_INPUT_LENGTH, stdin); if (feof(stdin) || strlen(menu_item) == 1) { break; From e913bf53ed2d29a0e598171f54677f9c06b3e1bd Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 18:33:43 +0000 Subject: [PATCH 024/151] Initializacia --- cv1/program.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cv1/program.c b/cv1/program.c index 380dfcc..f7fdf7b 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -32,6 +32,7 @@ int main() { // Read the menu items while (1) { + printf("Zadaj jedalny listok: "); // Print the prompt for each menu item fgets(menu_item, MAX_INPUT_LENGTH, stdin); if (feof(stdin) || strlen(menu_item) == 1) { break; From 828b632b59f7e6123a6a6598a689bd5f45fefbf5 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 18:36:14 +0000 Subject: [PATCH 025/151] Initializacia --- cv1/program.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index f7fdf7b..0e8d7d5 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -4,7 +4,6 @@ #define MAX_INPUT_LENGTH 100 -// Define the "Hack3r scr1pt" mapping char hack3r_script_mapping[][2] = { {'0', 'o'}, {'1', 'i'}, @@ -23,23 +22,19 @@ int main() { char menu_item[MAX_INPUT_LENGTH]; int count = 0; - // Read the ingredient to be searched printf("Zadaj hladanu surovinu: "); fgets(ingredient, MAX_INPUT_LENGTH, stdin); - ingredient[strcspn(ingredient, "\n")] = 0; // Remove newline character + ingredient[strcspn(ingredient, "\n")] = 0; - printf("Zadaj jedalny listok:\n"); // Print the prompt + printf("Zadaj jedalny listok:\n"); - // Read the menu items while (1) { - printf("Zadaj jedalny listok: "); // Print the prompt for each menu item fgets(menu_item, MAX_INPUT_LENGTH, stdin); if (feof(stdin) || strlen(menu_item) == 1) { break; } - menu_item[strcspn(menu_item, "\n")] = 0; // Remove newline character + menu_item[strcspn(menu_item, "\n")] = 0; - // Apply the "Hack3r scr1pt" mapping to the name char name_hack3r[MAX_INPUT_LENGTH]; int j = 0; for (int i = 0; menu_item[i]; i++) { @@ -57,14 +52,12 @@ int main() { } name_hack3r[j] = 0; - // Search for the ingredient in the name if (strstr(name_hack3r, ingredient) != NULL) { printf("%s\n", menu_item); count++; } } - // Display the count of successful searches printf("Nacitanych %d poloziek.\n", count); return 0; From c2ccf2dfa6fee20ba2083b006ad2cc78d6bba029 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 18:39:17 +0000 Subject: [PATCH 026/151] Initializacia --- cv1/program.c | 115 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 45 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 0e8d7d5..358af72 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -1,60 +1,85 @@ #include -#include +#include #include +#include -#define MAX_INPUT_LENGTH 100 +#define LINESIZE 100 +#define MENU_SIZE 100 -char hack3r_script_mapping[][2] = { - {'0', 'o'}, - {'1', 'i'}, - {'2', 'z'}, - {'3', 'e'}, - {'4', 'a'}, - {'5', 's'}, - {'6', 'b'}, - {'7', 't'}, - {'8', 'b'}, - {'9', 'q'} +struct pizza { + char name[LINESIZE]; + float price; }; +char hacker_script(char l) { + switch (tolower(l)) { + case 'o': return '0'; + case 'i': return '1'; + case 'z': return '2'; + case 'e': return '3'; + case 'a': return '4'; + case 's': return '5'; + case 'b': return '6'; + case 't': return '7'; + case 'q': return '9'; + default: return tolower(l); + } +} + +void transform_to_hacker_script(const char *src, char *dest) { + while (*src) { + *dest++ = hacker_script(*src++); + } + *dest = '\0'; +} + +int contains_normalized(const char *name, const char *search) { + char transformed_name[LINESIZE], transformed_search[LINESIZE]; + + transform_to_hacker_script(name, transformed_name); + transform_to_hacker_script(search, transformed_search); + + return strstr(transformed_name, transformed_search) != NULL; +} + +int read_pizza(struct pizza *item) { + char line[LINESIZE]; + + if (!fgets(item->name, LINESIZE, stdin)) { + return 0; + } + item->name[strcspn(item->name, "\n")] = '\0'; + + if (!fgets(line, LINESIZE, stdin)) { + return 0; + } + + item->price = strtof(line, NULL); + return 1; +} + int main() { - char ingredient[MAX_INPUT_LENGTH]; - char menu_item[MAX_INPUT_LENGTH]; + struct pizza menu[MENU_SIZE]; + char search[LINESIZE]; int count = 0; - printf("Zadaj hladanu surovinu: "); - fgets(ingredient, MAX_INPUT_LENGTH, stdin); - ingredient[strcspn(ingredient, "\n")] = 0; + printf("Zadaj hladanu surovinu:\n"); + if (!fgets(search, LINESIZE, stdin)) { + printf("Error reading input.\n"); + return 1; + } + search[strcspn(search, "\n")] = '\0'; printf("Zadaj jedalny listok:\n"); + while (count < MENU_SIZE && read_pizza(&menu[count])) { + count++; + } - while (1) { - fgets(menu_item, MAX_INPUT_LENGTH, stdin); - if (feof(stdin) || strlen(menu_item) == 1) { - break; - } - menu_item[strcspn(menu_item, "\n")] = 0; - - char name_hack3r[MAX_INPUT_LENGTH]; - int j = 0; - for (int i = 0; menu_item[i]; i++) { - int found = 0; - for (int k = 0; k < 10; k++) { - if (menu_item[i] == hack3r_script_mapping[k][0]) { - name_hack3r[j++] = hack3r_script_mapping[k][1]; - found = 1; - break; - } - } - if (!found) { - name_hack3r[j++] = tolower(menu_item[i]); - } - } - name_hack3r[j] = 0; - - if (strstr(name_hack3r, ingredient) != NULL) { - printf("%s\n", menu_item); - count++; + int found_count = 0; + for (int i = 0; i < count; i++) { + if (contains_normalized(menu[i].name, search)) { + printf("%s\n%.2f\n", menu[i].name, menu[i].price); + found_count++; } } From d1379c84273996085cc14cd44ee4b527f30086de Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 18:42:16 +0000 Subject: [PATCH 027/151] Initializacia --- cv1/program.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cv1/program.c b/cv1/program.c index 358af72..9a382f6 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -83,6 +83,10 @@ int main() { } } + if (found_count == 0) { + printf("\n"); + } + printf("Nacitanych %d poloziek.\n", count); return 0; From 882b546c876720fe353fb559ee4245512b6c460f Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 18:44:48 +0000 Subject: [PATCH 028/151] Initializacia --- cv1/program.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 9a382f6..bcd33f9 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -12,17 +12,18 @@ struct pizza { }; char hacker_script(char l) { - switch (tolower(l)) { - case 'o': return '0'; - case 'i': return '1'; - case 'z': return '2'; - case 'e': return '3'; - case 'a': return '4'; - case 's': return '5'; - case 'b': return '6'; - case 't': return '7'; - case 'q': return '9'; - default: return tolower(l); + switch (l) { + case '0': return 'o'; + case '1': return 'i'; + case '2': return 'z'; + case '3': return 'e'; + case '4': return 'a'; + case '5': return 's'; + case '6': return 'b'; + case '7': return 't'; + case '8': return 'b'; + case '9': return 'q'; + default: return l; } } From d8ded9eed69d4d07d1feb6fc7443bd89d99b9327 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 18:48:04 +0000 Subject: [PATCH 029/151] Initializacia --- cv1/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv1/program.c b/cv1/program.c index bcd33f9..e54cd48 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -36,7 +36,7 @@ void transform_to_hacker_script(const char *src, char *dest) { int contains_normalized(const char *name, const char *search) { char transformed_name[LINESIZE], transformed_search[LINESIZE]; - +q transform_to_hacker_script(name, transformed_name); transform_to_hacker_script(search, transformed_search); From 8b64f9d216326a1c50d73b84429ecce1398573a7 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 18:49:34 +0000 Subject: [PATCH 030/151] Initializacia --- cv1/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv1/program.c b/cv1/program.c index e54cd48..bcd33f9 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -36,7 +36,7 @@ void transform_to_hacker_script(const char *src, char *dest) { int contains_normalized(const char *name, const char *search) { char transformed_name[LINESIZE], transformed_search[LINESIZE]; -q + transform_to_hacker_script(name, transformed_name); transform_to_hacker_script(search, transformed_search); From fdb278d71d3fe6e25eb315b3ba6648878a8ea7fb Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 18:56:18 +0000 Subject: [PATCH 031/151] Initializacia --- cv1/program.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index bcd33f9..1ee33bb 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -36,25 +36,20 @@ void transform_to_hacker_script(const char *src, char *dest) { int contains_normalized(const char *name, const char *search) { char transformed_name[LINESIZE], transformed_search[LINESIZE]; - transform_to_hacker_script(name, transformed_name); transform_to_hacker_script(search, transformed_search); - return strstr(transformed_name, transformed_search) != NULL; } int read_pizza(struct pizza *item) { char line[LINESIZE]; - if (!fgets(item->name, LINESIZE, stdin)) { return 0; } item->name[strcspn(item->name, "\n")] = '\0'; - if (!fgets(line, LINESIZE, stdin)) { return 0; } - item->price = strtof(line, NULL); return 1; } @@ -66,7 +61,6 @@ int main() { printf("Zadaj hladanu surovinu:\n"); if (!fgets(search, LINESIZE, stdin)) { - printf("Error reading input.\n"); return 1; } search[strcspn(search, "\n")] = '\0'; @@ -89,6 +83,5 @@ int main() { } printf("Nacitanych %d poloziek.\n", count); - return 0; -} \ No newline at end of file +} From a61de64ccd94f6fab8e437599d842568403b56b7 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 18:58:16 +0000 Subject: [PATCH 032/151] Initializacia --- cv1/program.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 1ee33bb..bd2350f 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -13,23 +13,22 @@ struct pizza { char hacker_script(char l) { switch (l) { - case '0': return 'o'; - case '1': return 'i'; - case '2': return 'z'; - case '3': return 'e'; - case '4': return 'a'; - case '5': return 's'; - case '6': return 'b'; - case '7': return 't'; - case '8': return 'b'; - case '9': return 'q'; - default: return l; + case 'o': return '0'; + case 'i': return '1'; + case 'z': return '2'; + case 'e': return '3'; + case 'a': return '4'; + case 's': return '5'; + case 'b': return '6'; + case 't': return '7'; + case 'q': return '9'; + default: return tolower(l); } } void transform_to_hacker_script(const char *src, char *dest) { while (*src) { - *dest++ = hacker_script(*src++); + *dest++ = hacker_script(tolower(*src++)); } *dest = '\0'; } From 79e0d5633eccd12e6fda10f71daab50c033b4375 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 19:00:52 +0000 Subject: [PATCH 033/151] Initializacia --- cv1/program.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index bd2350f..1ee33bb 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -13,22 +13,23 @@ struct pizza { char hacker_script(char l) { switch (l) { - case 'o': return '0'; - case 'i': return '1'; - case 'z': return '2'; - case 'e': return '3'; - case 'a': return '4'; - case 's': return '5'; - case 'b': return '6'; - case 't': return '7'; - case 'q': return '9'; - default: return tolower(l); + case '0': return 'o'; + case '1': return 'i'; + case '2': return 'z'; + case '3': return 'e'; + case '4': return 'a'; + case '5': return 's'; + case '6': return 'b'; + case '7': return 't'; + case '8': return 'b'; + case '9': return 'q'; + default: return l; } } void transform_to_hacker_script(const char *src, char *dest) { while (*src) { - *dest++ = hacker_script(tolower(*src++)); + *dest++ = hacker_script(*src++); } *dest = '\0'; } From efd3e34cb55a88033bcd519f283c58a0057c6f37 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 19:04:28 +0000 Subject: [PATCH 034/151] Initializacia --- cv1/program.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cv1/program.c b/cv1/program.c index 1ee33bb..b5ccdb8 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -38,6 +38,14 @@ int contains_normalized(const char *name, const char *search) { char transformed_name[LINESIZE], transformed_search[LINESIZE]; transform_to_hacker_script(name, transformed_name); transform_to_hacker_script(search, transformed_search); + + for (int i = 0; transformed_name[i]; i++) { + transformed_name[i] = tolower(transformed_name[i]); + } + for (int i = 0; transformed_search[i]; i++) { + transformed_search[i] = tolower(transformed_search[i]); + } + return strstr(transformed_name, transformed_search) != NULL; } From 1746f22b4e73c43b7f176d3459bb0fc2f0a614d5 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 19:05:32 +0000 Subject: [PATCH 035/151] Initializacia --- cv1/program.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index b5ccdb8..dbd3329 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -73,7 +73,7 @@ int main() { } search[strcspn(search, "\n")] = '\0'; - printf("Zadaj jedalny listok:\n"); + printf("Zadaj jedalny listok:"); while (count < MENU_SIZE && read_pizza(&menu[count])) { count++; } @@ -81,7 +81,7 @@ int main() { int found_count = 0; for (int i = 0; i < count; i++) { if (contains_normalized(menu[i].name, search)) { - printf("%s\n%.2f\n", menu[i].name, menu[i].price); + printf("\n%s\n%.2f\n", menu[i].name, menu[i].price); found_count++; } } From 943f74a75ec92f044ad95236c8ea749021e0bdf5 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 19:06:27 +0000 Subject: [PATCH 036/151] Initializacia --- cv1/program.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index dbd3329..b03c006 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -81,14 +81,11 @@ int main() { int found_count = 0; for (int i = 0; i < count; i++) { if (contains_normalized(menu[i].name, search)) { - printf("\n%s\n%.2f\n", menu[i].name, menu[i].price); + printf("%s\n%.2f\n", menu[i].name, menu[i].price); found_count++; } } - if (found_count == 0) { - printf("\n"); - } printf("Nacitanych %d poloziek.\n", count); return 0; From 75c55a1bb92b48da251b13e752cb2191e4ce5f84 Mon Sep 17 00:00:00 2001 From: Kozar Date: Wed, 2 Oct 2024 19:07:44 +0000 Subject: [PATCH 037/151] Initializacia --- cv1/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv1/program.c b/cv1/program.c index b03c006..c4d322b 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -73,7 +73,7 @@ int main() { } search[strcspn(search, "\n")] = '\0'; - printf("Zadaj jedalny listok:"); + printf("Zadaj jedalny listok:\n"); while (count < MENU_SIZE && read_pizza(&menu[count])) { count++; } From e09f5c99e3015efbf8fe09d6ee464b03f7640013 Mon Sep 17 00:00:00 2001 From: Kozar Date: Mon, 7 Oct 2024 16:55:46 +0000 Subject: [PATCH 038/151] Initializacia --- cv2/program.c | 84 +++++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 39 deletions(-) diff --git a/cv2/program.c b/cv2/program.c index 2e9c03d..b3f3f81 100644 --- a/cv2/program.c +++ b/cv2/program.c @@ -1,55 +1,61 @@ #include #include #include -#include -#define LINE_SIZE 100 -#define LIST_SIZE 100 +#define MAX_NAME_LENGTH 100 +#define MAX_ITEMS 100 -struct pizza{ - char name[LINE_SIZE]; +typedef struct { + char name[MAX_NAME_LENGTH]; float price; -} +} Pizza; -int read_pizza_list(struct pizza* list){ - char buffer[LINE_SIZE] - while(fgets(buffer, LINE_SIZT, stdin) == 0){ - +int compare(const void *a, const void *b) { + Pizza *pizzaA = (Pizza *)a; + Pizza *pizzaB = (Pizza *)b; + + if (pizzaA->price != pizzaB->price) { + return (pizzaA->price > pizzaB->price) - (pizzaA->price < pizzaB->price); } + return strcasecmp(pizzaA->name, pizzaB->name); } -int read_item(struct pizza* list) { - -} - - -int main(){ - struct pizza vacerajsia = {.name = "Vajcova pizza", .price = 0.2}; - printf("Pizza: %s, cena: %f/n", vacerajsia.name, vacerajsia.price -0.1); +int read_pizza_list(Pizza *menu) { + int count = 0; + char input[MAX_NAME_LENGTH]; - // Prechadzajte vsetky miesta jedalneho listka - int counter = 0; - for (int i=0; i< LIST_SIZE; i++){ - struct pizza item; - memset(&item,0,sizeof(struct pizza)); - // Nacitajte polozku do pomocnej premennej - // Na nacitanie pouzite vlastny kod - int r = read_item(&item); - if (r){ - // Ak sa nacitanie podarilo, skopirujte polozku do pola - memcpy(&listok[i],&item,sizeof(struct pizza)); - // Spocitame uspesne nacitane polozky - counter += 1; - } - else{ - // Ak sa nacitanie nepodarilo, nasli sme poslednu polozku - // Prerusim nacitanie + // Nacitame pizza + while (count < MAX_ITEMS && fgets(input, sizeof(input), stdin)) { + input[strcspn(input, "\n")] = 0; // Odstran znak noveho riadku + + // Nacitame cenu pizze + char price_str[10]; + if (fgets(price_str, sizeof(price_str), stdin) == NULL) { break; } + + float price = atof(price_str); + if (price <= 0) { + break; + } + + strncpy(menu[count].name, input, MAX_NAME_LENGTH - 1); + menu[count].price = price; + count++; } - // Na konci budemem mat nacitany jedalny listok - // V premennej counter je pocet uspesne nacitanych poloziek - return 0; + return count; } - +int main() { + Pizza menu[MAX_ITEMS]; + + int item_count = read_pizza_list(menu); + + qsort(menu, item_count, sizeof(Pizza), compare); + + for (int i = 0; i < item_count; i++) { + printf("%s\n%.6f\n", menu[i].name, menu[i].price); + } + + return 0; +} From f406e24e0c16b0fba3ddc39ac870cc79810f8d2b Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 8 Oct 2024 15:28:33 +0200 Subject: [PATCH 039/151] Initializacia --- cv3/program | Bin 0 -> 16192 bytes cv3/program.c | 37 +++++++++++++++++++++++++++++++++++++ cv4/program.c | 0 3 files changed, 37 insertions(+) create mode 100755 cv3/program create mode 100644 cv3/program.c create mode 100644 cv4/program.c diff --git a/cv3/program b/cv3/program new file mode 100755 index 0000000000000000000000000000000000000000..5129b5614948935f1ce4a47a24b3d7a0a1e7acfd GIT binary patch literal 16192 zcmeHOYitzP6~4Q?oCffc@G#JX4TXw;yx3r#5n;g?#uX12Y_(0(4(r`ndzF2-yR(f= zD{6_-g20mVhoUq;Kxzb1Q;A4bMAfJ@g%XHV6k1gx>L1dU%BZ9P)3l@wY`=5oobhmGkTf?D{k}^R(t4O*YahNzO`qyv;5Lau}G<+{m zPpZj~Cu+{o#~pyyDc8bdv4;5xK=P}jN)`OHLn}e)AtCvVR}M{aG=hqcgZw6uie*2( z%Ka1+z1v=toKd3s+r^1wfFkJiqud;?*J^cq!&vO)_6{+MABp65n*C0*pWtn7Pf+qn zIib&5&Zi$6praz__v>aqKW=f{lpwW1WzP*e^)T(VvEQPo4x{|o1+J6eTb0k$uv$cJPnX-yjSEgiJ#r7S|*+SlGPjqH2 zG}M(VNkPLgO0g}{9oC<9|oCNqsjuf^OFL`Q%AH`F@OgH|qbPS8ja2_3+iN8i#*x9Qfnyw)U3Bp~lO` zz=pTci^{Cu!1Ax@SnYyuLqq}wHhcue7??CduPXEamFu+&`pND*BkV70 z`&GXnc=~~H__lHGFB^?>_a+#ji^kOl_Dlpg$N_39*VDS6;!pYO-!K5RDlh9W4s7V8 zs&V*+J=Hj}Aq`>p-3OJ*a0`U-sA_R0U|i%?Rf1AaJl{VC(f#KlW=oR)iy zL&lL=i{WStv<&_%rP;TJFCZw6s5~1-`Z1majKgmY_k%l2=km`PW1! zFJ&y7sk>`W8lDQpWehz!96c`Gkx14-2{I65Ajm+Ffgl4x27(L(83-~EWFW{ukb#HI zKnU-2T8hO&FXF2D)bEb{OwBR zC@>5B0q{-WcHpabDwQ{Z^sbXiXy0xX>WzfvPn}XTh-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<-SPIlhSwX$X|6l@LGMrrCqV5X>~RK1pTm~ K%=0<;MD;IfD6+T! literal 0 HcmV?d00001 diff --git a/cv3/program.c b/cv3/program.c new file mode 100644 index 0000000..5654e5b --- /dev/null +++ b/cv3/program.c @@ -0,0 +1,37 @@ +#include +#include + +#define LINE_SIZE 100 +#define STACK_SIZE 100 + +struct stack{ + float values[LINE_SIZE]; + int size; +} + +void print_stack(struct stack* stack){ + for (int i = 0; i < stack->size; i++){ + printf("%.0f", stack->values[i]); + } + printf("\n"); +} + +int main(){ + char input[LINE_SIZE]; float y; + memset(&mystack, 0, sizzeof(struct stack)); + + while(fgets(input, LINE_SIZE, stdin) != NULL){ + input[strlen(input - 1)] = '\0'; + if(sscanf(input, "\f", &y) == 1){ + printf("Success!\n"); + assert(mystack.size < STACK_SIZE); + mystack.values[mystack.size] = y; + mystack.size ++; + } esle{ + return 1; + } + print_stack(&mystack); + } + return 0; +} + diff --git a/cv4/program.c b/cv4/program.c new file mode 100644 index 0000000..e69de29 From 0f5e10398bf564500f5c06307edd1a78f26ec716 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 8 Oct 2024 15:30:56 +0200 Subject: [PATCH 040/151] Initializacia# --- cv1/program.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cv1/program.c b/cv1/program.c index 4f791d9..103a7fe 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -1,5 +1,7 @@ #include + int main() { + return 0; } From 223d9acafb7612bdd6c09d88ede593c360ec089c Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 8 Oct 2024 15:45:13 +0200 Subject: [PATCH 041/151] Initializacia --- cv3/program.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index 5654e5b..60e0c23 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -1,5 +1,8 @@ #include #include +#include +#include +#include #define LINE_SIZE 100 #define STACK_SIZE 100 @@ -17,8 +20,8 @@ void print_stack(struct stack* stack){ } int main(){ - char input[LINE_SIZE]; float y; - memset(&mystack, 0, sizzeof(struct stack)); + char input[LINE_SIZE]; float y; struct stack mystack; + memset(&mystack, 0, sizeof(struct stack)); while(fgets(input, LINE_SIZE, stdin) != NULL){ input[strlen(input - 1)] = '\0'; @@ -27,7 +30,7 @@ int main(){ assert(mystack.size < STACK_SIZE); mystack.values[mystack.size] = y; mystack.size ++; - } esle{ + } else{ return 1; } print_stack(&mystack); From fdc279f9d3cc05707abcf24357517304164f8bbb Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 8 Oct 2024 15:48:01 +0200 Subject: [PATCH 042/151] Initializacia --- cv3/program | Bin 16192 -> 16456 bytes cv3/program.c | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/cv3/program b/cv3/program index 5129b5614948935f1ce4a47a24b3d7a0a1e7acfd..7e95f957ac607ce8b63d5083956ff452fd564481 100755 GIT binary patch delta 3179 zcmZ`*Yiv_T7M|-z9H$O`B-EG^a$OpV0{U=`3lSZOOIq*ZC9rABB;SnY#Ws+#hnEfrlkN-9X`kFa8UduHxT zWGwBm?wtF5=ggUN=W#sglhX+)waRhOPM9=miX^v=mjAIJmaoBB{^%`F!Gc~x3wm%! zo*gep8Wft?G)(C{d}0+Ej`<$dXLTCB2>p`Np5$Ih?v;c;OaFE^%9>BEZqR7b0PpFV z-T!ZdBp)FOX8n=k3-`V*FFW{~`JuUUeS1lXd%oThhPU(^Tq`h`NS2WEB!QT6R`{oW zozx5qdZ+XhYd?T~gH!Uc_noZmWNnPLa8JJq8n+st#jr`bNj)Kr=tq6A^bJfHypTY2 z$FOO8FcN9+jRrb`;lm^lI2=9{3PhqoWV(al9@5?39chn}qkYi`i9~x3xA&lGLjy9Q zu3#^e8=F@=vza{qLetJ&foe~+rv^?N_r&%14LbZ8SWDj|V&oit42p!dIBLE=#2F43 z67(73TrtB20vvxZ`VOw2o}A;jZ*|yAFz!XfRK$X^%~66xql57z!Pk)Q8bTa!D6d@7 z!APF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RB0%jPpgbmiW^(SbiDWE9zjpA`11DDjciaH>!kB3Zs)%je?-S zlIoz$dzs^Ph@zDD8%H0ER0o~BOH(4;uC8=cvHq`uKuvhIv3Y~ cxPGa_$Nr_PfuHNc&ZbJknB)rZOVz^v04PJ{R{#J2 diff --git a/cv3/program.c b/cv3/program.c index 60e0c23..d9d2e9b 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -10,7 +10,7 @@ struct stack{ float values[LINE_SIZE]; int size; -} +}; void print_stack(struct stack* stack){ for (int i = 0; i < stack->size; i++){ From d525b294727b0d663f634728971a824d4fd116fb Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 13 Oct 2024 09:11:15 +0000 Subject: [PATCH 043/151] Update cv1/program.c --- cv1/program.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index 2790b3c..c4d322b 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -1,10 +1,4 @@ #include -<<<<<<< HEAD - -int main() { - - return 0; -======= #include #include #include @@ -31,7 +25,6 @@ char hacker_script(char l) { case '9': return 'q'; default: return l; } ->>>>>>> e09f5c99e3015efbf8fe09d6ee464b03f7640013 } void transform_to_hacker_script(const char *src, char *dest) { From bc1099ece91ef775c077046d17bca3e7b75148a8 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 13 Oct 2024 09:13:29 +0000 Subject: [PATCH 044/151] Initializacia --- cv3/program.c | 128 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 96 insertions(+), 32 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index d9d2e9b..ec49735 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -1,40 +1,104 @@ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #define LINE_SIZE 100 -#define STACK_SIZE 100 +#define STACK_SIZE 10 -struct stack{ - float values[LINE_SIZE]; - int size; +struct stack { + float values[STACK_SIZE]; + int size; }; -void print_stack(struct stack* stack){ - for (int i = 0; i < stack->size; i++){ - printf("%.0f", stack->values[i]); - } - printf("\n"); +void print_stack(struct stack* stack) { + for (int i = 0; i < stack->size; i++) { + printf("%.2f ", stack->values[i]); + } + printf("\n"); } -int main(){ - char input[LINE_SIZE]; float y; struct stack mystack; - memset(&mystack, 0, sizeof(struct stack)); - - while(fgets(input, LINE_SIZE, stdin) != NULL){ - input[strlen(input - 1)] = '\0'; - if(sscanf(input, "\f", &y) == 1){ - printf("Success!\n"); - assert(mystack.size < STACK_SIZE); - mystack.values[mystack.size] = y; - mystack.size ++; - } else{ - return 1; - } - print_stack(&mystack); - } - return 0; +void push_stack(struct stack* stack, float value) { + if (stack->size >= STACK_SIZE) { + printf("Chyba: zasobnik je plny\n"); + exit(1); + } + stack->values[stack->size] = value; + stack->size++; +} + +float pop_stack(struct stack* stack) { + if (stack->size == 0) { + printf("Chyba: zasobnik je prazdny\n"); + exit(1); + } + stack->size--; + return stack->values[stack->size]; +} + +int is_operator(char* input) { + return (strcmp(input, "+") == 0 || strcmp(input, "-") == 0 || + strcmp(input, "*") == 0 || strcmp(input, "/") == 0); +} + +void perform_operation(struct stack* stack, char* operator) { + if (stack->size < 2) { + printf("Chyba: nedostatok operandov\n"); + exit(1); + } + + float b = pop_stack(stack); + float a = pop_stack(stack); + float result; + + if (strcmp(operator, "+") == 0) { + result = a + b; + } else if (strcmp(operator, "-") == 0) { + result = a - b; + } else if (strcmp(operator, "*") == 0) { + result = a * b; + } else if (strcmp(operator, "/") == 0) { + if (b == 0) { + printf("Chyba: delenie nulou\n"); + exit(1); + } + result = a / b; + } else { + printf("Chyba: neplatna operacia\n"); + exit(1); + } + + push_stack(stack, result); +} + +int main() { + char input[LINE_SIZE]; + float value; + struct stack mystack; + memset(&mystack, 0, sizeof(struct stack)); + + while (fgets(input, LINE_SIZE, stdin) != NULL) { + // Remove trailing newline character + input[strlen(input) - 1] = '\0'; + + // Try to parse input as a number + if (sscanf(input, "%f", &value) == 1) { + push_stack(&mystack, value); + } + // If it's not a number, check if it's a valid operator + else if (is_operator(input)) { + perform_operation(&mystack, input); + } + // Invalid input + else { + printf("Chyba: neplatny vstup\n"); + return 1; + } + + // Print stack after each input + print_stack(&mystack); + } + + return 0; } - From 9867b831a83289d8a8b47d4b7a68c33a86279d98 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 13 Oct 2024 09:25:57 +0000 Subject: [PATCH 045/151] Initializacia --- cv3/program.c | 56 ++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index ec49735..40e58c0 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -2,54 +2,59 @@ #include #include #include -#include -#define LINE_SIZE 100 #define STACK_SIZE 10 +// Stack structure struct stack { float values[STACK_SIZE]; int size; }; -void print_stack(struct stack* stack) { - for (int i = 0; i < stack->size; i++) { - printf("%.2f ", stack->values[i]); +// Function to print the stack +void print_stack(struct stack* s) { + for (int i = 0; i < s->size; i++) { + printf("%.2f", s->values[i]); + if (i < s->size - 1) { + printf(" "); // Print space between values + } } printf("\n"); } -void push_stack(struct stack* stack, float value) { - if (stack->size >= STACK_SIZE) { +// Function to push a value onto the stack +void push_stack(struct stack* s, float value) { + if (s->size >= STACK_SIZE) { printf("Chyba: zasobnik je plny\n"); exit(1); } - stack->values[stack->size] = value; - stack->size++; + s->values[s->size++] = value; } -float pop_stack(struct stack* stack) { - if (stack->size == 0) { +// Function to pop a value from the stack +float pop_stack(struct stack* s) { + if (s->size == 0) { printf("Chyba: zasobnik je prazdny\n"); exit(1); } - stack->size--; - return stack->values[stack->size]; + return s->values[--s->size]; } +// Check if input is an operator int is_operator(char* input) { return (strcmp(input, "+") == 0 || strcmp(input, "-") == 0 || strcmp(input, "*") == 0 || strcmp(input, "/") == 0); } -void perform_operation(struct stack* stack, char* operator) { - if (stack->size < 2) { +// Perform the operation on the top of the stack +void perform_operation(struct stack* s, char* operator) { + if (s->size < 2) { printf("Chyba: nedostatok operandov\n"); exit(1); } - float b = pop_stack(stack); - float a = pop_stack(stack); + float b = pop_stack(s); + float a = pop_stack(s); float result; if (strcmp(operator, "+") == 0) { @@ -69,20 +74,20 @@ void perform_operation(struct stack* stack, char* operator) { exit(1); } - push_stack(stack, result); + push_stack(s, result); } int main() { - char input[LINE_SIZE]; - float value; + char input[100]; struct stack mystack; - memset(&mystack, 0, sizeof(struct stack)); + mystack.size = 0; - while (fgets(input, LINE_SIZE, stdin) != NULL) { - // Remove trailing newline character - input[strlen(input) - 1] = '\0'; + // Reading input from stdin until EOF or an error occurs + while (fgets(input, sizeof(input), stdin) != NULL) { + input[strlen(input) - 1] = '\0'; // Remove newline character // Try to parse input as a number + float value; if (sscanf(input, "%f", &value) == 1) { push_stack(&mystack, value); } @@ -96,9 +101,10 @@ int main() { return 1; } - // Print stack after each input + // Print stack after each valid input print_stack(&mystack); } + printf("no input\n"); return 0; } From 1fbb3ac28656fd9bdbd481d15c815a86b5dfb2a7 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 13 Oct 2024 09:29:51 +0000 Subject: [PATCH 046/151] Initializacia --- cv3/program.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index 40e58c0..abb8659 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -5,24 +5,23 @@ #define STACK_SIZE 10 -// Stack structure struct stack { float values[STACK_SIZE]; int size; }; -// Function to print the stack void print_stack(struct stack* s) { for (int i = 0; i < s->size; i++) { printf("%.2f", s->values[i]); if (i < s->size - 1) { - printf(" "); // Print space between values + printf(" "); + } else { + printf(" "); } } printf("\n"); } -// Function to push a value onto the stack void push_stack(struct stack* s, float value) { if (s->size >= STACK_SIZE) { printf("Chyba: zasobnik je plny\n"); @@ -31,7 +30,6 @@ void push_stack(struct stack* s, float value) { s->values[s->size++] = value; } -// Function to pop a value from the stack float pop_stack(struct stack* s) { if (s->size == 0) { printf("Chyba: zasobnik je prazdny\n"); @@ -40,13 +38,11 @@ float pop_stack(struct stack* s) { return s->values[--s->size]; } -// Check if input is an operator int is_operator(char* input) { return (strcmp(input, "+") == 0 || strcmp(input, "-") == 0 || strcmp(input, "*") == 0 || strcmp(input, "/") == 0); } -// Perform the operation on the top of the stack void perform_operation(struct stack* s, char* operator) { if (s->size < 2) { printf("Chyba: nedostatok operandov\n"); @@ -82,26 +78,23 @@ int main() { struct stack mystack; mystack.size = 0; - // Reading input from stdin until EOF or an error occurs while (fgets(input, sizeof(input), stdin) != NULL) { - input[strlen(input) - 1] = '\0'; // Remove newline character + input[strlen(input) - 1] = '\0'; - // Try to parse input as a number float value; if (sscanf(input, "%f", &value) == 1) { push_stack(&mystack, value); } - // If it's not a number, check if it's a valid operator + else if (is_operator(input)) { perform_operation(&mystack, input); } - // Invalid input + else { printf("Chyba: neplatny vstup\n"); return 1; } - // Print stack after each valid input print_stack(&mystack); } From 0c73d2017a4ffa2ea34811891d6b02cb353bd905 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 13 Oct 2024 09:31:18 +0000 Subject: [PATCH 047/151] Initializacia --- cv3/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv3/program.c b/cv3/program.c index abb8659..b8093a9 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -61,7 +61,7 @@ void perform_operation(struct stack* s, char* operator) { result = a * b; } else if (strcmp(operator, "/") == 0) { if (b == 0) { - printf("Chyba: delenie nulou\n"); + printf("division by zero\n"); exit(1); } result = a / b; From 50e07c78dfb9eb65c2a50b2617fd67b90f86b0b5 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 13 Oct 2024 09:32:39 +0000 Subject: [PATCH 048/151] Initializacia --- cv3/program.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index b8093a9..1c63355 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -25,7 +25,7 @@ void print_stack(struct stack* s) { void push_stack(struct stack* s, float value) { if (s->size >= STACK_SIZE) { printf("Chyba: zasobnik je plny\n"); - exit(1); + exit(0); } s->values[s->size++] = value; } @@ -33,7 +33,7 @@ void push_stack(struct stack* s, float value) { float pop_stack(struct stack* s) { if (s->size == 0) { printf("Chyba: zasobnik je prazdny\n"); - exit(1); + exit(0); } return s->values[--s->size]; } @@ -46,7 +46,7 @@ int is_operator(char* input) { void perform_operation(struct stack* s, char* operator) { if (s->size < 2) { printf("Chyba: nedostatok operandov\n"); - exit(1); + exit(0); } float b = pop_stack(s); @@ -62,7 +62,7 @@ void perform_operation(struct stack* s, char* operator) { } else if (strcmp(operator, "/") == 0) { if (b == 0) { printf("division by zero\n"); - exit(1); + exit(0); } result = a / b; } else { From fba426a0ebeece6ab6e80b4f66a038385b265f28 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 13 Oct 2024 09:33:36 +0000 Subject: [PATCH 049/151] Initializacia --- cv3/{program.c => wprogram.c} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename cv3/{program.c => wprogram.c} (97%) diff --git a/cv3/program.c b/cv3/wprogram.c similarity index 97% rename from cv3/program.c rename to cv3/wprogram.c index 1c63355..82de3a0 100644 --- a/cv3/program.c +++ b/cv3/wprogram.c @@ -91,7 +91,7 @@ int main() { } else { - printf("Chyba: neplatny vstup\n"); + printf("bad input\n"); return 1; } From 824447cc6e76b60f05030b66129eb2acd353a8d3 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 13 Oct 2024 09:35:46 +0000 Subject: [PATCH 050/151] Update cv3/program.c --- cv3/{wprogram.c => program.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cv3/{wprogram.c => program.c} (100%) diff --git a/cv3/wprogram.c b/cv3/program.c similarity index 100% rename from cv3/wprogram.c rename to cv3/program.c From d832de78627e09605cdd54ba1007405946f47e6a Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 13 Oct 2024 09:36:47 +0000 Subject: [PATCH 051/151] Initializacia --- cv3/program.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index 82de3a0..00adfe3 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -67,7 +67,7 @@ void perform_operation(struct stack* s, char* operator) { result = a / b; } else { printf("Chyba: neplatna operacia\n"); - exit(1); + exit(0); } push_stack(s, result); @@ -92,7 +92,7 @@ int main() { else { printf("bad input\n"); - return 1; + return 0; } print_stack(&mystack); From 952c832f80241a2eb0258b01fb0d6e0427f88178 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 13 Oct 2024 09:39:28 +0000 Subject: [PATCH 052/151] Initializacia --- cv3/program.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index 00adfe3..008266a 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -14,9 +14,9 @@ void print_stack(struct stack* s) { for (int i = 0; i < s->size; i++) { printf("%.2f", s->values[i]); if (i < s->size - 1) { - printf(" "); + printf(" "); } else { - printf(" "); + printf(" "); } } printf("\n"); @@ -25,7 +25,7 @@ void print_stack(struct stack* s) { void push_stack(struct stack* s, float value) { if (s->size >= STACK_SIZE) { printf("Chyba: zasobnik je plny\n"); - exit(0); + exit(1); } s->values[s->size++] = value; } @@ -33,7 +33,7 @@ void push_stack(struct stack* s, float value) { float pop_stack(struct stack* s) { if (s->size == 0) { printf("Chyba: zasobnik je prazdny\n"); - exit(0); + exit(1); } return s->values[--s->size]; } @@ -46,7 +46,7 @@ int is_operator(char* input) { void perform_operation(struct stack* s, char* operator) { if (s->size < 2) { printf("Chyba: nedostatok operandov\n"); - exit(0); + exit(1); } float b = pop_stack(s); @@ -62,12 +62,12 @@ void perform_operation(struct stack* s, char* operator) { } else if (strcmp(operator, "/") == 0) { if (b == 0) { printf("division by zero\n"); - exit(0); + exit(1); } result = a / b; } else { printf("Chyba: neplatna operacia\n"); - exit(0); + exit(1); } push_stack(s, result); @@ -84,15 +84,11 @@ int main() { float value; if (sscanf(input, "%f", &value) == 1) { push_stack(&mystack, value); - } - - else if (is_operator(input)) { + } else if (is_operator(input)) { perform_operation(&mystack, input); - } - - else { + } else { printf("bad input\n"); - return 0; + return 1; } print_stack(&mystack); From 94189ce4e451dd3023137d7660be0217919a04b0 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 13 Oct 2024 09:42:19 +0000 Subject: [PATCH 053/151] Initializacia --- cv3/program.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index 008266a..44580b1 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -25,7 +25,7 @@ void print_stack(struct stack* s) { void push_stack(struct stack* s, float value) { if (s->size >= STACK_SIZE) { printf("Chyba: zasobnik je plny\n"); - exit(1); + exit(0); } s->values[s->size++] = value; } @@ -33,7 +33,7 @@ void push_stack(struct stack* s, float value) { float pop_stack(struct stack* s) { if (s->size == 0) { printf("Chyba: zasobnik je prazdny\n"); - exit(1); + exit(0); } return s->values[--s->size]; } @@ -46,7 +46,7 @@ int is_operator(char* input) { void perform_operation(struct stack* s, char* operator) { if (s->size < 2) { printf("Chyba: nedostatok operandov\n"); - exit(1); + exit(0); } float b = pop_stack(s); @@ -62,12 +62,12 @@ void perform_operation(struct stack* s, char* operator) { } else if (strcmp(operator, "/") == 0) { if (b == 0) { printf("division by zero\n"); - exit(1); + exit(0); } result = a / b; } else { printf("Chyba: neplatna operacia\n"); - exit(1); + exit(0); } push_stack(s, result); @@ -88,7 +88,7 @@ int main() { perform_operation(&mystack, input); } else { printf("bad input\n"); - return 1; + return 0; } print_stack(&mystack); From 69fdc54776a4bf087999eb6aea1e0e9e97585e01 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 13 Oct 2024 09:44:19 +0000 Subject: [PATCH 054/151] Initializacia --- cv3/program.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index 44580b1..1bce719 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #define STACK_SIZE 10 @@ -43,6 +43,12 @@ int is_operator(char* input) { strcmp(input, "*") == 0 || strcmp(input, "/") == 0); } +int is_valid_float(char* input) { + char* endptr; + strtod(input, &endptr); + return *endptr == '\0'; +} + void perform_operation(struct stack* s, char* operator) { if (s->size < 2) { printf("Chyba: nedostatok operandov\n"); @@ -81,8 +87,8 @@ int main() { while (fgets(input, sizeof(input), stdin) != NULL) { input[strlen(input) - 1] = '\0'; - float value; - if (sscanf(input, "%f", &value) == 1) { + if (is_valid_float(input)) { + float value = atof(input); push_stack(&mystack, value); } else if (is_operator(input)) { perform_operation(&mystack, input); From c8d22b9589f99f92073c85837ff9bc36b0b61ae6 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 13 Oct 2024 09:45:37 +0000 Subject: [PATCH 055/151] Initializacia --- cv3/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv3/program.c b/cv3/program.c index 1bce719..f536259 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -51,7 +51,7 @@ int is_valid_float(char* input) { void perform_operation(struct stack* s, char* operator) { if (s->size < 2) { - printf("Chyba: nedostatok operandov\n"); + printf("not enough operands\n"); exit(0); } From b35831b69129c85770d107d17adfb5fc9e95f24e Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 13 Oct 2024 09:46:30 +0000 Subject: [PATCH 056/151] Initializacia --- cv3/program.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index f536259..88a101b 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -24,7 +24,7 @@ void print_stack(struct stack* s) { void push_stack(struct stack* s, float value) { if (s->size >= STACK_SIZE) { - printf("Chyba: zasobnik je plny\n"); + printf("full stack\n"); exit(0); } s->values[s->size++] = value; @@ -32,7 +32,7 @@ void push_stack(struct stack* s, float value) { float pop_stack(struct stack* s) { if (s->size == 0) { - printf("Chyba: zasobnik je prazdny\n"); + printf("empty stack\n"); exit(0); } return s->values[--s->size]; From 9a7f29797fdd45972acb4d46de85d70744b7bbea Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 15 Oct 2024 12:34:20 +0000 Subject: [PATCH 057/151] Initializacia --- cv4/Makefile | 13 +++++++++++++ cv4/a_train.c | 18 ++++++++++++++++++ cv4/a_train.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ cv4/main.c | 17 +++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 cv4/Makefile create mode 100644 cv4/a_train.c create mode 100644 cv4/a_train.h create mode 100644 cv4/main.c diff --git a/cv4/Makefile b/cv4/Makefile new file mode 100644 index 0000000..3c2c463 --- /dev/null +++ b/cv4/Makefile @@ -0,0 +1,13 @@ +CFLAGS= -std=c99 -g -Wall + +all: train + +%.o: %.c + gcc -c -o $@ $< $(CFLAGS) + +train: main.o a_train.o + gcc main.o a_train.o -o train + +clean: + rm *.o train + diff --git a/cv4/a_train.c b/cv4/a_train.c new file mode 100644 index 0000000..3ecfbc8 --- /dev/null +++ b/cv4/a_train.c @@ -0,0 +1,18 @@ +#include "a_train.h" +#include + +struct car* add_car(struct car* first,const char* target) { + return NULL; +} + +void print_train(struct car* first) { +} + +void cancel_train(struct car* first) { +} + + +struct car* clear_train(struct car* first, const char* target) { + return NULL; +} + diff --git a/cv4/a_train.h b/cv4/a_train.h new file mode 100644 index 0000000..5982bfe --- /dev/null +++ b/cv4/a_train.h @@ -0,0 +1,51 @@ +#ifndef TRAIN_H +#define TRAIN_H +#define SIZE 100 + +/** + * Jeden vozen vlaku + */ +struct car { + /** + * Nazov cielovej stanice + */ + char value[SIZE]; + /** + * Smenik na dalsi vozen + */ + struct car* next; +}; + +/** + * Prida vozen na koniec vlaku. + * + * @arg nazov cielovej stanice, ktory sa ma priradit novemu voznu. + * @return smernik na zaciatok vlaku. + */ +struct car* add_car(struct car* first,const char* target); + + +/** + * Vypise vsetky vozne vo vlaku + * + * @arg smernik na prvy vozen + */ +void print_train(struct car* first); + +/** + * Zrusenie vsetkych voznov vo vlaku. + * @arg smernik na prvy vozen + */ +void cancel_train(struct car* first); + +/** + * Vyradenie vsetkych voznov, ktorych cielova stanica je target + * + * @arg smernik na prvy vozen + * @arg cielova stanica, ktora sa ma vyradit z vlaku. + * @return smernik na novy prvy vozen + * + */ +struct car* clear_train(struct car* first,const char* target); + +#endif // TRAIN_H diff --git a/cv4/main.c b/cv4/main.c new file mode 100644 index 0000000..d64f05a --- /dev/null +++ b/cv4/main.c @@ -0,0 +1,17 @@ +#include "a_train.h" +#include + +// Testovaci subor pre vlak +int main(){ + struct car* train = NULL; + train = add_car(train,"Presov"); + train = add_car(train,"Bratislava"); + train = add_car(train,"Levoca"); + train = add_car(train,"Spiska Nova Ves"); + print_train(train); + clear_train(train,"Levoca"); + print_train(train); + cancel_train(train); + + return 0; +} From 5e43f512cfb0106578fc32abbfbb0d2a7d4f6870 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 15 Oct 2024 12:36:12 +0000 Subject: [PATCH 058/151] Initializacia --- cv4/program.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 cv4/program.c diff --git a/cv4/program.c b/cv4/program.c deleted file mode 100644 index e69de29..0000000 From e84146551bc51b65256b4b68b2fe414294696f6f Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 15 Oct 2024 13:43:00 +0000 Subject: [PATCH 059/151] Initializacia --- cv4/a_train.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/cv4/a_train.c b/cv4/a_train.c index 3ecfbc8..edd3bfb 100644 --- a/cv4/a_train.c +++ b/cv4/a_train.c @@ -1,18 +1,67 @@ #include "a_train.h" #include +#include +#include struct car* add_car(struct car* first,const char* target) { - return NULL; + struct car* last = first; + struct car* newcar* = calloc(1, sizeof(struct car)); + strcpy(newcar->value, target); + if (last != NULL){ + struct car* current = last; + while(current->next != NULL){ + current = current->next + } + current->next = newcar; + } else{ + last = newcar; + return last; + } + return first; } void print_train(struct car* first) { + if(first != NULL){ + struct car* current = first; + while(current->next != NULL){ + printf("%s\n", current->value); + current = current->next; + } + } } void cancel_train(struct car* first) { + struct car* current = first; + while(first != NULL){ + current = current->next; + free(first); + first = current; + } } struct car* clear_train(struct car* first, const char* target) { - return NULL; + if (first = NULL){ + return NULL; + } + struct car* current = first, new_first = first; + if (first != NULL){ + if(strcmp(first->destination, target) == 0){ + new_first = new_first->next; + free(first); + first = new_first; + } + } + + while (first->next != NULL) { + current = first->next; + if (strcmp(current->destination, target) == 0) { + first->next = current->next; + free(current); + } else { + first = current; + } + } + return new_first; } From 58777d185006b18282bdde1200c82275297aa534 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 15 Oct 2024 13:46:29 +0000 Subject: [PATCH 060/151] Initializacia --- cv4/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv4/main.c b/cv4/main.c index d64f05a..8c6a5c4 100644 --- a/cv4/main.c +++ b/cv4/main.c @@ -9,7 +9,7 @@ int main(){ train = add_car(train,"Levoca"); train = add_car(train,"Spiska Nova Ves"); print_train(train); - clear_train(train,"Levoca"); + tran = clear_train(train,"Levoca"); print_train(train); cancel_train(train); From df2f224230a1d35f302b9ef0ee49c5215b06e2dd Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 15 Oct 2024 13:46:47 +0000 Subject: [PATCH 061/151] Initializacia --- cv4/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv4/main.c b/cv4/main.c index 8c6a5c4..a445b0d 100644 --- a/cv4/main.c +++ b/cv4/main.c @@ -9,7 +9,7 @@ int main(){ train = add_car(train,"Levoca"); train = add_car(train,"Spiska Nova Ves"); print_train(train); - tran = clear_train(train,"Levoca"); + train = clear_train(train,"Levoca"); print_train(train); cancel_train(train); From 6448cb0e4df871ad932053fa51b7044c1b1ac2ce Mon Sep 17 00:00:00 2001 From: Kozar Date: Sat, 19 Oct 2024 11:47:21 +0000 Subject: [PATCH 062/151] Initializacia --- cv4/a_train.c | 68 +++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/cv4/a_train.c b/cv4/a_train.c index edd3bfb..4be60ce 100644 --- a/cv4/a_train.c +++ b/cv4/a_train.c @@ -21,47 +21,47 @@ struct car* add_car(struct car* first,const char* target) { } void print_train(struct car* first) { - if(first != NULL){ - struct car* current = first; - while(current->next != NULL){ - printf("%s\n", current->value); - current = current->next; - } - } + // if(first != NULL){ + // struct car* current = first; + // while(current->next != NULL){ + // printf("%s\n", current->value); + // current = current->next; + // } + // } } void cancel_train(struct car* first) { - struct car* current = first; - while(first != NULL){ - current = current->next; - free(first); - first = current; - } + // struct car* current = first; + // while(first != NULL){ + // current = current->next; + // free(first); + // first = current; + // } } struct car* clear_train(struct car* first, const char* target) { - if (first = NULL){ - return NULL; - } - struct car* current = first, new_first = first; - if (first != NULL){ - if(strcmp(first->destination, target) == 0){ - new_first = new_first->next; - free(first); - first = new_first; - } - } + // if (first = NULL){ + // return NULL; + // } + // struct car* current = first, new_first = first; + // if (first != NULL){ + // if(strcmp(first->destination, target) == 0){ + // new_first = new_first->next; + // free(first); + // first = new_first; + // } + // } - while (first->next != NULL) { - current = first->next; - if (strcmp(current->destination, target) == 0) { - first->next = current->next; - free(current); - } else { - first = current; - } - } - return new_first; + // while (first->next != NULL) { + // current = first->next; + // if (strcmp(current->destination, target) == 0) { + // first->next = current->next; + // free(current); + // } else { + // first = current; + // } + // } + // return new_first; } From 2e25765e5d90fe45a38db591666461517fab628e Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 20 Oct 2024 12:58:05 +0000 Subject: [PATCH 063/151] Initializacia --- cv4/a_train.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cv4/a_train.c b/cv4/a_train.c index 4be60ce..f881ba2 100644 --- a/cv4/a_train.c +++ b/cv4/a_train.c @@ -3,20 +3,22 @@ #include #include -struct car* add_car(struct car* first,const char* target) { +struct car* add_car(struct car* first, const char* target) { struct car* last = first; - struct car* newcar* = calloc(1, sizeof(struct car)); + struct car* newcar = calloc(1, sizeof(struct car)); strcpy(newcar->value, target); - if (last != NULL){ + + if (last != NULL) { struct car* current = last; - while(current->next != NULL){ - current = current->next + while (current->next != NULL) { + current = current->next; } current->next = newcar; - } else{ + } else { last = newcar; return last; } + return first; } From 9cd93271e18936196462d93369f3f2fa3dd1f17c Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 20 Oct 2024 12:59:11 +0000 Subject: [PATCH 064/151] Initializacia --- cv4/a_train.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cv4/a_train.c b/cv4/a_train.c index f881ba2..021890c 100644 --- a/cv4/a_train.c +++ b/cv4/a_train.c @@ -23,13 +23,13 @@ struct car* add_car(struct car* first, const char* target) { } void print_train(struct car* first) { - // if(first != NULL){ - // struct car* current = first; - // while(current->next != NULL){ - // printf("%s\n", current->value); - // current = current->next; - // } - // } + if(first != NULL){ + struct car* current = first; + while(current->next != NULL){ + printf("%s\n", current->value); + current = current->next; + } + } } void cancel_train(struct car* first) { From 6c79f0d25092133328c30cd8d77ab0a3527b322d Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 20 Oct 2024 13:00:06 +0000 Subject: [PATCH 065/151] Initializacia --- cv4/a_train.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/cv4/a_train.c b/cv4/a_train.c index 021890c..b175afa 100644 --- a/cv4/a_train.c +++ b/cv4/a_train.c @@ -43,27 +43,27 @@ void cancel_train(struct car* first) { struct car* clear_train(struct car* first, const char* target) { - // if (first = NULL){ - // return NULL; - // } - // struct car* current = first, new_first = first; - // if (first != NULL){ - // if(strcmp(first->destination, target) == 0){ - // new_first = new_first->next; - // free(first); - // first = new_first; - // } - // } + if (first = NULL){ + return NULL; + } + struct car* current = first, new_first = first; + if (first != NULL){ + if(strcmp(first->destination, target) == 0){ + new_first = new_first->next; + free(first); + first = new_first; + } + } - // while (first->next != NULL) { - // current = first->next; - // if (strcmp(current->destination, target) == 0) { - // first->next = current->next; - // free(current); - // } else { - // first = current; - // } - // } - // return new_first; + while (first->next != NULL) { + current = first->next; + if (strcmp(current->destination, target) == 0) { + first->next = current->next; + free(current); + } else { + first = current; + } + } + return new_first; } From 91662d4ed85c3c0aa06b94e9d7b297fb412a5f45 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 20 Oct 2024 13:02:50 +0000 Subject: [PATCH 066/151] Initializacia --- cv4/a_train.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cv4/a_train.c b/cv4/a_train.c index b175afa..5e87327 100644 --- a/cv4/a_train.c +++ b/cv4/a_train.c @@ -48,7 +48,7 @@ struct car* clear_train(struct car* first, const char* target) { } struct car* current = first, new_first = first; if (first != NULL){ - if(strcmp(first->destination, target) == 0){ + if(strcmp(first->value, target) == 0){ new_first = new_first->next; free(first); first = new_first; @@ -57,7 +57,7 @@ struct car* clear_train(struct car* first, const char* target) { while (first->next != NULL) { current = first->next; - if (strcmp(current->destination, target) == 0) { + if (strcmp(current->value, target) == 0) { first->next = current->next; free(current); } else { From c79715105ca63b19c3b9de21c4c43db00e8fa9df Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 20 Oct 2024 13:06:03 +0000 Subject: [PATCH 067/151] Initializacia --- cv4/a_train.c | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/cv4/a_train.c b/cv4/a_train.c index 5e87327..c117b1a 100644 --- a/cv4/a_train.c +++ b/cv4/a_train.c @@ -33,37 +33,40 @@ void print_train(struct car* first) { } void cancel_train(struct car* first) { - // struct car* current = first; - // while(first != NULL){ - // current = current->next; - // free(first); - // first = current; - // } + struct car* current = first; + while(first != NULL){ + current = current->next; + free(first); + first = current; + } } struct car* clear_train(struct car* first, const char* target) { - if (first = NULL){ + if (first == NULL) { return NULL; } - struct car* current = first, new_first = first; - if (first != NULL){ - if(strcmp(first->value, target) == 0){ - new_first = new_first->next; - free(first); - first = new_first; - } + + struct car* current = first; + struct car* previous = NULL; + + while (current != NULL && strcmp(current->value, target) == 0) { + struct car* temp = current; + first = current->next; + current = first; + free(temp); } - while (first->next != NULL) { - current = first->next; + while (current != NULL) { if (strcmp(current->value, target) == 0) { - first->next = current->next; + previous->next = current->next; free(current); + current = previous->next; } else { - first = current; + previous = current; + current = current->next; } } - return new_first; -} + return first; +} From e9423093a56213d830ccf0438dc29b38c9486c31 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 29 Oct 2024 14:29:22 +0100 Subject: [PATCH 068/151] Initalizacia --- a1/program.c | 1 + 1 file changed, 1 insertion(+) create mode 100644 a1/program.c diff --git a/a1/program.c b/a1/program.c new file mode 100644 index 0000000..53c5fdf --- /dev/null +++ b/a1/program.c @@ -0,0 +1 @@ +#include From 138c5f4e91ee67862f9667b63cb32ef5688d7f27 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 29 Oct 2024 17:46:23 +0100 Subject: [PATCH 069/151] Initializacia --- a1/main | Bin 0 -> 16336 bytes a1/program.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100755 a1/main diff --git a/a1/main b/a1/main new file mode 100755 index 0000000000000000000000000000000000000000..5bc851cc3d552394b9de71f11fe1d97c3af4ec6b GIT binary patch literal 16336 zcmeHOeQXrR6`!*)IK*(rS1^!2khX+t-}$oV&eZ zNC~bCDV9N{Qqs~YsuJ~&BxLayNCR$CISt|Zdo%Oa z=hZo>qDrl*ozw1{_j?~R^JaE$c6Vlf!=?=-fq>vtD%J?%20{vnXhCSD&VWS3N-+iJ z`QkP)5&Q&+DS1Q@NL9L2GM1KWycCq|Dk)Qh-l|~1lxs+o?8ZxNlaz$1(Cr|*G7@Rt zOXoPLk|ED7E!XX1T4+bHIaa0gkF6d{JGI>*P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L^%=Szt!nn|0M6_zPqFfF;U_0h3U`!a7 z&-2gFIQCwD({%Y-o!ttyU+f|(Lv^K8NO|lii8@EL!<-uDh~S e=gwM1_jsIhxvWc%FU9Py(H|SqT#tc=75@Uo{Av#X literal 0 HcmV?d00001 diff --git a/a1/program.c b/a1/program.c index 53c5fdf..bd9dc62 100644 --- a/a1/program.c +++ b/a1/program.c @@ -1 +1,72 @@ #include +#include + +#define MAX_LEN 101 + +typedef struct { + char bracket; + int position; +} StackItem; + +int is_opening(char ch) { + return ch == '(' || ch == '{' || ch == '[' || ch == '<'; +} + +int is_closing(char ch) { + return ch == ')' || ch == '}' || ch == ']' || ch == '>'; +} + +char matching_bracket(char ch) { + switch (ch) { + case ')': return '('; + case '}': return '{'; + case ']': return '['; + case '>': return '<'; + default: return 0; + } +} + +void check_brackets(const char *line) { + StackItem stack[MAX_LEN]; + int stack_top = -1; + + printf("Read: %s\n", line); + + for (int i = 0; line[i] != '\0'; i++) { + char ch = line[i]; + + if (is_opening(ch)) { + if (stack_top < MAX_LEN - 1) { + stack[++stack_top].bracket = ch; + stack[stack_top].position = i; + } else { + printf("Error: Stack overflow\n"); + return; + } + } else if (is_closing(ch)) { + if (stack_top >= 0 && stack[stack_top].bracket == matching_bracket(ch)) { + stack_top--; + } else { + printf("Crossed bracket %c in %d, expected %c\n", ch, i, + stack_top >= 0 ? matching_bracket(stack[stack_top].bracket) : '#'); + return; + } + } + } + + if (stack_top >= 0) { + printf("Unmatched bracket %c in %d\n", stack[stack_top].bracket, stack[stack_top].position); + } else { + printf("All brackets OK\n"); + } +} + +int main() { + char line[MAX_LEN]; + if (fgets(line, sizeof(line), stdin)) { + line[strcspn(line, "\n")] = '\0'; + check_brackets(line); + } + return 0; +} + From 647c26db9ad47711f008e3201cebcf71fa65c640 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 29 Oct 2024 17:51:58 +0100 Subject: [PATCH 070/151] Initializacia --- a1/main | Bin 16336 -> 16336 bytes a1/program.c | 7 +++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/a1/main b/a1/main index 5bc851cc3d552394b9de71f11fe1d97c3af4ec6b..f534ddc294f0d7c03622541afe8241e288ce91e9 100755 GIT binary patch delta 759 zcmcamf1!Q@2P3B;D+3r9P8MX;=QLn~@C-J4GU_u5u26t*;q>HAruQQMkGeBk?5|b3 z*<)_A`+?)qkF$0tZ0=#s=Ve^6`H#Q@Mn>DocZG6APXP6L^s?^d0aBgEUl{-W|No`- zvkZkd+Ht_*?A18V`jmE&>ujI$h& z74QH5?*MXc0O<`t`UQ{%#e&6$|NjeswBpDA{~rM95FpLK$iUDJq!oblZ6NIcr2l`O zd`>}2>Htui8c-R73%dY_QUPKUAb#;~vXG*hqykVHEDn+b0udlC0b+^Cfr{dcmXk9T z&R{^CfS3ZF@CTCtYk7j0OVJ04S4h9Apps)bY=Eq{GRE(S%23I@f^TDHrW03u=<;{X5v delta 707 zcmYLHO=uHA7~R=4ZPISLiA{*XLUxs;v7v;Rg0Vy_wxL__Pz33*E!2aE+Cu~nY9cY! zkQSpKg$RO*Ab5~AtUm#h5E1|Il3uhIp{R!~QKBMJXzcjSrqO}jH}mGb_kA-=C02CTs7wRU;(l8nB}Aw3oPw9 zc5#bm%?i^^GH_uZpPOYOvZaB$RYSn^Al%ZZB%0M$J)& z+cwX{q>r63k|`ZWnw_$XX_Mt>FJqMj`vX1WJ=^-cN$IN*V@5YHVi9jdFR7%DZD6>q z8Gcjkv43fYGQabND6L?MU&E3hKF+|RI< zz}`os%QD9gceW}CgJF{hZ6=OmE(_MVr`mTXI$*ZV3)%h<5!99bB?D=JOMy`mhqr+b zNZs8h5+Xn@I6p6dJ-oktb$hicseK3U G^M3)3RuDP> diff --git a/a1/program.c b/a1/program.c index bd9dc62..4cd5e11 100644 --- a/a1/program.c +++ b/a1/program.c @@ -44,11 +44,14 @@ void check_brackets(const char *line) { return; } } else if (is_closing(ch)) { - if (stack_top >= 0 && stack[stack_top].bracket == matching_bracket(ch)) { + if (stack_top == -1) { + printf("Unexpected closing bracket %c in %d\n", ch, i); + return; + } else if (stack[stack_top].bracket == matching_bracket(ch)) { stack_top--; } else { printf("Crossed bracket %c in %d, expected %c\n", ch, i, - stack_top >= 0 ? matching_bracket(stack[stack_top].bracket) : '#'); + matching_bracket(stack[stack_top].bracket)); return; } } From 2fa7918d0ba1069d238bdd1978044e6209ca72bb Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 29 Oct 2024 17:55:12 +0100 Subject: [PATCH 071/151] Initializacia --- a1/main | Bin 16336 -> 16416 bytes a1/program.c | 19 +++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/a1/main b/a1/main index f534ddc294f0d7c03622541afe8241e288ce91e9..c4fcfac18b07659e0c16f2df788301212a8f0596 100755 GIT binary patch delta 2707 zcmZ`*e@qld6rQ=`4o<+kJ;3!8y*rEwDz_X$LEr>Lbct;cqm5OJP@qCYMLD9jnnMv& zf+mNrHMVK(Y161}+DhmT{-_qC)fhF!MynK%U;}pn^8V~o3P%0jCmVvsT_M@uBlBC2)RwD8ek;I0Ec!Ih*&VA9fA4_H=8@Syvp}|5h!s}?Wrq?h=GsytI zR|k02IBy^!C^pZe23Thn9Y!u@5H8dVc4I8?zFCBe=D7ICC^i-@nMH4$CR49RxtDDL zRzJNRAH_$(Q;an$IxfC%6l;d`Xb~!r?H|R)^i)T$joD{QiP<&L(|*=(@AF%f0jsl>2~TrG{V`RaeHa!A$+QmYg~@5_ zkRmNJm&t9ud8{jU-0{cBoxTNVgwOw@DB)UM$5~S;d@kH9>WI8q`owy&^hsOf4Sxz= z0-0@*m3}8)0;z40RDX0^q`)r@CHJObtf2|L+ZiPEu3`|^I~VQ=iO^}!p45-`MeaD) zi#!Q;K2?-+?cY366lM+x~- z_CD*bL#S*!(Tk+glFHqkZ?m8sXEDO0(GxP&pdG_>wzIB$!1~pD-}PbdS=dAjn|nI8 z#nSdElhC13xRM}Ex{A-)NZv9FbC}JmCQo6&J}$7U&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+O`*a2QMFhSm%7%~h`E8VFi4HrvC|(R%W3x4gd`pPExjBiT z<;$Gg^;EN&pv@L8f86^XZkdMcM42^p&rFI)Mg(Qj$9IYI8WM(jLoTJzV-TU+U`dKq zDu(ObY%`}fc?nsGg=02 zr9@4KtqV=o|gOcf%lu(!c6E^P{X)((a$<8n{9Oa1iSL60YpTkxm zjds96Aw8!DDY7efZKyr4kxfILKet#yU4hLg#Ks@Va;!m?&F}Q6@xA!WBN?Z%G{)xbRdz#RMX2qks%tut_M|_3p(BI6-H-{}Lu=&iH!f2slG(jrE2}5 zxC0~hb_6Z2j$%Ys9HI8RrcnC@)966`!fOeKUAx=X?$}=6vZ<-D z!L{*?`b}FKTU?o&T+KUNnGFdfxNV!t?sTnuF8=lsI$vAH&Ix>xNbB#id=POA@f2bV zkv*N_Nm+gk(LE*06Nq()>@0W((S>*uu?kVXua)HnpziDiBj}oirli^!e|s}<>cbxU zO_n!6jeC*Tg%;|I%?$0>Td=1hzlssOr6G1>FM%U&C!Q)pIIf2o_xvSykp)aGgB@Ts zPgvj9EK4$k+O=An#$q%P!aS{*7Tg=CSolIBoHBYG>Jbp;M**tiZ4I2va|#(LisayI z6vp$Mv=3(TB+axAmgJ|?QCOZY2~qw+^P`irLTA2Hm}KV#Hh$WZR2a%%Nyoq}Iq5Lu zNLy$>^h%X5CS7+}c>;}ny08(QL#1}_y309l~l#a+2Kc)IXy*?Wq7%X~;4rKcGQW(+b2l|RPQ0f9& zDhbm(Efq&0i0m-`%&V9Rky6P##@R6#D)pOFdBLQ@OsRjieAF^(gwg3PC diff --git a/a1/program.c b/a1/program.c index 4cd5e11..c936066 100644 --- a/a1/program.c +++ b/a1/program.c @@ -26,6 +26,16 @@ char matching_bracket(char ch) { } } +char expected_closing(char ch) { + switch (ch) { + case '(': return ')'; + case '{': return '}'; + case '[': return ']'; + case '<': return '>'; + default: return 0; + } +} + void check_brackets(const char *line) { StackItem stack[MAX_LEN]; int stack_top = -1; @@ -51,14 +61,19 @@ void check_brackets(const char *line) { stack_top--; } else { printf("Crossed bracket %c in %d, expected %c\n", ch, i, - matching_bracket(stack[stack_top].bracket)); + expected_closing(stack[stack_top].bracket)); return; } } } if (stack_top >= 0) { - printf("Unmatched bracket %c in %d\n", stack[stack_top].bracket, stack[stack_top].position); + printf("Missing closing brackets:"); + while (stack_top >= 0) { + printf(" %c", expected_closing(stack[stack_top].bracket)); + stack_top--; + } + printf("\n"); } else { printf("All brackets OK\n"); } From 3a54e83d467ecc18eee305a96e50f6ad1896db61 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 29 Oct 2024 17:58:51 +0100 Subject: [PATCH 072/151] Initializacia --- a1/main | Bin 16416 -> 16416 bytes a1/program.c | 5 +++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/a1/main b/a1/main index c4fcfac18b07659e0c16f2df788301212a8f0596..987823d81a1cceeaa544c738304ae45b640c9f8d 100755 GIT binary patch delta 705 zcmYL{OK4L;6o%*AB=)9FOoBIRAK2W|m|`hOZSjE#SWN8oQ4O}Df?!+QRRaahqLE^o z2CK0RMh6!zgopt_Yf-O{c42yKuZ54wcqTzTF!M40`RAXrn9Mk2 z#^Heo=4BHp)iQN}*Blngr?9#Yyx_>X%Ey1CNuelNX#e$X4{Og)JPOn7Owckq)9Y5J z4Ogt-R_h#31?Zu#*X;!>t&xV|CcP~A{ug5(o9QcQ z{r=hCjM;KpGOyo4F>!wmO^|rbL1Ie_mE3-j+ie&(T#nNxQBbBr`he1GbT^?TYSJg@ zZl`DH?iPG76-ws@QN@?_7`I-~q8_d)DQ8V7;tg*d!q&^6DP6k2g&v%xG^#Rn^gCut zf3uC~EG!c8)wb!Ul2{Ry#0zmz?Q3YOyym(())9%g`p@*89vY0EbsauHaAv4A>^hDU z@bO2Bj7=j~kdKk8$R*^-PmD#8q0fxHM~)zkK*&90Ba$J5$nGzU4Ine$7`ud&(8~+X z9U(Ac2f9(VSHHv1&0Gyu*f|<;wd2xhhwQ2LVYejn78Z}-PdCxHya7(o8*)8F=sfOY z^eyfx{UO)8Kj45}{BwlX+9!oQ)-_7PVDJl;3XzaHlzljiT@5sJS5Zw6X}V2v9fP1Mx1SOrN8^64S#x3tmPY6Oop75%z-#{h>vjgV On~7X@5H%LKBm4nqx%FKD delta 643 zcmYk4PiPZS5XN_QO}pC~V>C-!DRegw5?V@H|De@IC>pyt6{}#Bf{G~!qFw^F2Wexh z5S!rExrhgef}|jdvRKnY+myzZfCqyj-V_8`=pn6m5UW1tC87@O`@Q$g%(t`b%Z@{K z9G=RclpR7f%IJom5*2Hws1<=AxTm$+@h>qYRy^L%u_wl-3mx7? zR&B0h-x(_{Sqo~Y;kGsgpuZ*RMf`Gp?FT6)xZ-S55qx&I%XZ5BQjf~Im{GVtgrs+9~ zQ+gZ3@ENUFuuSVCT-V!tA83F<{)@v~w%!mAIqQt1B=w1#>t#XUytP#!5 zeNePYoi8Lfj*0Gmn8s3fg{0Y?E`UKS?K%MwOW%E3h9yk&29=^p1{6h{?d^vgLMW*G TyEi?dy^5^YDr9RkloNjgMBeUf diff --git a/a1/program.c b/a1/program.c index c936066..3a9e3b1 100644 --- a/a1/program.c +++ b/a1/program.c @@ -69,8 +69,9 @@ void check_brackets(const char *line) { if (stack_top >= 0) { printf("Missing closing brackets:"); - while (stack_top >= 0) { - printf(" %c", expected_closing(stack[stack_top].bracket)); + printf(" "); + while (stack_top >= 0) { + printf("%c", expected_closing(stack[stack_top].bracket)); stack_top--; } printf("\n"); From 6c0c3cfee588a39a5d3a485e776ff2df6a4cd5f4 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 29 Oct 2024 17:00:08 +0000 Subject: [PATCH 073/151] Initializacia --- a1/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/a1/program.c b/a1/program.c index 3a9e3b1..1d0dc9e 100644 --- a/a1/program.c +++ b/a1/program.c @@ -60,7 +60,7 @@ void check_brackets(const char *line) { } else if (stack[stack_top].bracket == matching_bracket(ch)) { stack_top--; } else { - printf("Crossed bracket %c in %d, expected %c\n", ch, i, + printf("Crossed bracket %c in %d, expected %c\n ", ch, i, expected_closing(stack[stack_top].bracket)); return; } From 0a45896795aab6ca2ef47660726ec2abf73738dc Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 29 Oct 2024 17:01:15 +0000 Subject: [PATCH 074/151] Initializacia --- a1/program.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/a1/program.c b/a1/program.c index 1d0dc9e..0d06df5 100644 --- a/a1/program.c +++ b/a1/program.c @@ -55,12 +55,12 @@ void check_brackets(const char *line) { } } else if (is_closing(ch)) { if (stack_top == -1) { - printf("Unexpected closing bracket %c in %d\n", ch, i); + printf("Unexpected closing bracket %c in %d \n", ch, i); return; } else if (stack[stack_top].bracket == matching_bracket(ch)) { stack_top--; } else { - printf("Crossed bracket %c in %d, expected %c\n ", ch, i, + printf("Crossed bracket %c in %d, expected %c \n", ch, i, expected_closing(stack[stack_top].bracket)); return; } From ae048d93047f4f2e75d3e0755e4e2906945afb46 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 29 Oct 2024 17:02:15 +0000 Subject: [PATCH 075/151] Initializacia --- a1/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/a1/program.c b/a1/program.c index 0d06df5..1e54785 100644 --- a/a1/program.c +++ b/a1/program.c @@ -55,7 +55,7 @@ void check_brackets(const char *line) { } } else if (is_closing(ch)) { if (stack_top == -1) { - printf("Unexpected closing bracket %c in %d \n", ch, i); + printf("Unexpected closing bracket %c in %d\n", ch, i); return; } else if (stack[stack_top].bracket == matching_bracket(ch)) { stack_top--; From a5e76d9e908319361594bc8359e0c88bf397edf3 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 29 Oct 2024 18:04:22 +0100 Subject: [PATCH 076/151] Initializacia --- a1/main | Bin 16416 -> 16416 bytes a1/program.c | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/a1/main b/a1/main index 987823d81a1cceeaa544c738304ae45b640c9f8d..0bc7763cae257ff292d13f89b53474ae437349fc 100755 GIT binary patch delta 72 zcmV-O0Js03fB~R@0kC)j6z{%HeY8%!n6J~v=&!+0+0DdU5VMQ}G7$l`lfM*S0dSKa e6=VS$vxF7#3IQOKbs#RYq##@z0i?45Js$(I933_Q delta 70 zcmV-M0J;C5fB~R@0kC)j6bzGMl{T>(euA=4lccOf41BC$C9{kJG7$l_lfM*S0dJEZ c6=VS#vxF7#3X^sqF0-Q`T^s?UvjIIH1FHiV_5c6? diff --git a/a1/program.c b/a1/program.c index 3a9e3b1..c1dc6b5 100644 --- a/a1/program.c +++ b/a1/program.c @@ -60,7 +60,7 @@ void check_brackets(const char *line) { } else if (stack[stack_top].bracket == matching_bracket(ch)) { stack_top--; } else { - printf("Crossed bracket %c in %d, expected %c\n", ch, i, + printf("Crossed bracket %c in %d, expected %c \n", ch, i, expected_closing(stack[stack_top].bracket)); return; } @@ -89,3 +89,4 @@ int main() { return 0; } + From d9724563090a2c031804c367819cb26bccfb0685 Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 1 Nov 2024 11:00:11 +0100 Subject: [PATCH 077/151] Initializacia --- cv6/temp.c | 1 + 1 file changed, 1 insertion(+) create mode 100644 cv6/temp.c diff --git a/cv6/temp.c b/cv6/temp.c new file mode 100644 index 0000000..a8f9fd8 --- /dev/null +++ b/cv6/temp.c @@ -0,0 +1 @@ +Hello From 792ea488bfd5848b923798d69d42b1f0cde11551 Mon Sep 17 00:00:00 2001 From: Kozar Date: Fri, 1 Nov 2024 10:00:40 +0000 Subject: [PATCH 078/151] Initializacia --- cv6/Makefile | 13 +++++++ cv6/a_station.c | 33 ++++++++++++++++++ cv6/a_station.h | 91 +++++++++++++++++++++++++++++++++++++++++++++++++ cv6/main.c | 41 ++++++++++++++++++++++ 4 files changed, 178 insertions(+) create mode 100644 cv6/Makefile create mode 100644 cv6/a_station.c create mode 100644 cv6/a_station.h create mode 100644 cv6/main.c diff --git a/cv6/Makefile b/cv6/Makefile new file mode 100644 index 0000000..8cec7f4 --- /dev/null +++ b/cv6/Makefile @@ -0,0 +1,13 @@ +CFLAGS= -std=c99 -g -Wall -Werror + +all: station + +%.o: %.c + gcc -c -o $@ $< $(CFLAGS) + +station: main.o a_station.o + gcc $(CFLAGS) main.o a_station.o -o station + +clean: + rm *.o station + diff --git a/cv6/a_station.c b/cv6/a_station.c new file mode 100644 index 0000000..8f659d6 --- /dev/null +++ b/cv6/a_station.c @@ -0,0 +1,33 @@ +#include "a_station.h" +#include +#include + +struct station* create_station(){ + struct station* station = (struct station*)calloc(1,sizeof(struct station)); + station->tracks = (struct car**)calloc(STATION_SIZE, sizeof(struct car*)); + station->track_count = STATION_SIZE; + return station; +} + +void destroy_station(struct station* station){ +} + +int select_track(struct station* station, const char* target){ + return 0; +} + +void add_target_capacity(struct station* station,const char* target, int capacity){ +} + +int get_target_capacity(struct station* station,const char* target){ + return 0; +} + +int count_targets(struct station* station){ + return 0; +} + +int count_capacity(struct station* station){ + return 0; +} + diff --git a/cv6/a_station.h b/cv6/a_station.h new file mode 100644 index 0000000..ce8c733 --- /dev/null +++ b/cv6/a_station.h @@ -0,0 +1,91 @@ +#ifndef STATION_H +#define STATION_H +// Pocet trati k dispozicii +#define STATION_SIZE 10 +// Maximalny pocet znakov pre ulozenie nazvu cielovej stanice +#define TARGET_SIZE 36 + +/** + * Jeden zaznam o kapacite do cielovej stanice + */ +struct car { + // Cielova stanica / nazov + char value[TARGET_SIZE]; + // Pocet cestujuchich + int capacity; + // Smernik na dalsi zaznam + struct car* next; +}; + +/** + * Cela databaza zaznamov + */ +struct station { + // Dynamicke pole smernikov na zaznamy + // jeden zaznam ma typ struct car* + struct car** tracks; + // Velkost pola tracks + int track_count; +}; + + +/** + * Vytvori prazdnu stanicu. + * Alokuje pole smernikov tracks na pociatocnu kapacitu STATION_SIZE + * nastavi velkost capacity na STATION_SIZE + * @return smernik na prazdnu stanicu + */ +struct station* create_station(); + +/** + * Uvolni pamat + * @param smernik na databazu + */ +void destroy_station(struct station* station); + +/** + * Vyberie poziciu v poli station->tracks pre ulozenie zaznamu target + * + * Proces vyberu by mal splnat kriteria pre hash funkciu: + * - rovnaky retazec by mal vzdy mat rovnaky vysledok + * - pre rozne retazce by mali byt vysledky co najviac rozne + * + * @param smernik na databazu + * @param nazov cielovej stanice + * @return cislo v intervale 0 az N-1, kde N je station->track_count + */ +int select_track(struct station* station, const char* target); + +/** + * Zvysi zaznam o pocte cestujucich do danej cielovej stanice. + * + * Najprv sa vyberie cielova trat pomocou select_track(). Ak zaznam neexistuje, + * vytvori sa novy. Ak zaznam na danej trati (spojkovom zozname) existuje, cislo sa pripocita. + * V databaze nesmu byt dva zaznamy s rovnakou cielovou stanicou. + * + * @param smernik na databazu + * @param nazov cielovej stanice + */ +void add_target_capacity(struct station* station,const char* target, int capacity); + +/** + * Ziska zaznam o cielovej stanici. + * @param smernik na databazu + * @param nazov cielovej stanice + * + * @return kapacitu do cielovej stanice. Ak sa zaznam nenachedza, vrati nula. + */ +int get_target_capacity(struct station* station,const char* target); + +/** + * Spocita pocet cielovych stanic + * @param smernik na databazu + */ +int count_targets(struct station* station); + +/** + * Spocita kapacitu vo vsetkych zaznamoch + * @param smernik na databazu + */ +int count_capacity(struct station* station); +#endif diff --git a/cv6/main.c b/cv6/main.c new file mode 100644 index 0000000..a909625 --- /dev/null +++ b/cv6/main.c @@ -0,0 +1,41 @@ +#include "a_station.h" +#include +#include +#include + +void print_station(struct station* station){ + // Vypise celu stanicu + printf("station>>>\n"); + // Prechadza vsetky trate + for (int i = 0 ; i< station->track_count; i++){ + struct car* start = station->tracks[i]; + struct car* this = start; + // Prechadza vsetky vozne + while(this != NULL){ + printf("%s %d -> ",this->value,this->capacity); + this=this->next; + } + printf("NULL\n"); + } + printf("<< Date: Fri, 8 Nov 2024 13:23:35 +0000 Subject: [PATCH 079/151] Initializacia --- cv6/a_station.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cv6/a_station.c b/cv6/a_station.c index 8f659d6..030e70d 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -10,12 +10,20 @@ struct station* create_station(){ } void destroy_station(struct station* station){ + for (int i = 0; i < station->track_count; i++) { + struct car* current = station->tracks[i]; + while (current) { + struct car* temp = current; + current = current->next; + free(temp); + } + } + free(station->tracks); + free(station); } int select_track(struct station* station, const char* target){ - return 0; } - void add_target_capacity(struct station* station,const char* target, int capacity){ } From 1bd6f8da281df96c6dcd643629cc9a1e6873e50b Mon Sep 17 00:00:00 2001 From: Kozar Date: Fri, 8 Nov 2024 13:24:45 +0000 Subject: [PATCH 080/151] Initializacia --- cv6/a_station.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cv6/a_station.c b/cv6/a_station.c index 030e70d..f483f16 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -1,3 +1,4 @@ +#include #include "a_station.h" #include #include @@ -23,7 +24,14 @@ void destroy_station(struct station* station){ } int select_track(struct station* station, const char* target){ + size_t length = strlen(target); + int sum = 0; + for (size_t i = 0; i < length; i++) { + sum += target[i]; + } + return sum % station->track_count; } + void add_target_capacity(struct station* station,const char* target, int capacity){ } From a17788613644585c61758c0e73f9bfb8e7fc19ed Mon Sep 17 00:00:00 2001 From: Kozar Date: Fri, 8 Nov 2024 13:28:50 +0000 Subject: [PATCH 081/151] Initializacia --- cv6/a_station.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cv6/a_station.c b/cv6/a_station.c index f483f16..d104527 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -33,6 +33,23 @@ int select_track(struct station* station, const char* target){ } void add_target_capacity(struct station* station,const char* target, int capacity){ + int track = select_track(station, target); + struct car* current = station->tracks[track]; + + while (current) { + if (strcmp(current->value, target) == 0) { + current->capacity += capacity; + return; + } + current = current->next; + } + + struct car* new_car = malloc(sizeof(struct car)); + strncpy(new_car->value, target, TARGET_SIZE - 1); + new_car->value[TARGET_SIZE - 1] = '\0'; + new_car->capacity = capacity; + new_car->next = station->tracks[track]; + station->tracks[track] = new_car; } int get_target_capacity(struct station* station,const char* target){ From 2f4bf820c1657cb30626d282fd1907d4428dd2e7 Mon Sep 17 00:00:00 2001 From: Kozar Date: Fri, 8 Nov 2024 13:58:56 +0000 Subject: [PATCH 082/151] Initializacia --- cv6/a_station.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/cv6/a_station.c b/cv6/a_station.c index d104527..da0a69b 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -52,15 +52,41 @@ void add_target_capacity(struct station* station,const char* target, int capacit station->tracks[track] = new_car; } -int get_target_capacity(struct station* station,const char* target){ +int get_target_capacity(struct station* station, const char* target) { + int track = select_track(station, target); + struct car* current = station->tracks[track]; + + while (current) { + if (strcmp(current->value, target) == 0) { + return current->capacity; + } + current = current->next; + } + return 0; } -int count_targets(struct station* station){ - return 0; +int count_targets(struct station* station) { + int count = 0; + for (int i = 0; i < station->track_count; i++) { + struct car* current = station->tracks[i]; + while (current) { + count++; + current = current->next; + } + } + return count; } -int count_capacity(struct station* station){ - return 0; +int count_capacity(struct station* station) { + int total_capacity = 0; + for (int i = 0; i < station->track_count; i++) { + struct car* current = station->tracks[i]; + while (current) { + total_capacity += current->capacity; + current = current->next; + } + } + return total_capacity; } From 822de18141394a9af1970a8ea439b3dd8408a726 Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 9 Nov 2024 22:40:16 +0100 Subject: [PATCH 083/151] Initializacia --- cv7/program.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 cv7/program.c diff --git a/cv7/program.c b/cv7/program.c new file mode 100644 index 0000000..523b003 --- /dev/null +++ b/cv7/program.c @@ -0,0 +1,71 @@ +#include +#include +#include + +#define SIZE 100 + +struct tree{ + char value[SIZE]; + struct tree* left; + struct tree* right; +}; + +struct tree* read_tree(){ + char buffer[SIZE]; + memset(buffer,0,SIZE); + char* r = fgets(buffer,SIZE,stdin); + assert(r); + struct tree* node = calloc(1,sizeof(struct tree)); + memcpy(node->value,buffer,SIZE); + return node; +} + +struct tstruct tree* load_tree() { + struct tree* tree = read_tree(); + + tree->left = load_tree(); + tree->right = load_tree(); + + if (tree->value[0] == "*"){ + re + } +} + +void print_tree(struct tree* tree,int offset){ + for (int i = 0; i < offset; i++){ + printf(" "); + } + printf("%s",tree->question); + if (tree->left){ + print_tree(tree->left,offset +3); + print_tree(tree->right,offset +3); + } +} + +void destroy_tree(struct tree* tree){ + if(tree->left != NULL){ + destroy_tree(tree->left); + } + if(tree->right != NULL){ + destroy_tree(tree->right); + } + free(tree); +} + +void count_items(struct tree* tree, int* count){ + if(tree->left == NULL && tree->right == NULL){ + (*count)++ + }else{ + count_items(tree->left, count); + count_items(tree->right, count); + } +} + +int main() { + printf("Constructing the tree:\n"); + struct tree* root = test(); + printf("The tree structure:\n"); + print_tree(root, 0); + + return 0; +} From da7c980bcd65ea2ed0cbca792e664162fa79fcba Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 9 Nov 2024 22:41:39 +0100 Subject: [PATCH 084/151] Initializacia --- cv6/a_station.c | 66 +++++++++++++++++++++++++++++++++++++++++++++--- cv6/a_station.o | Bin 0 -> 8440 bytes cv6/main.o | Bin 0 -> 8608 bytes cv6/station | Bin 0 -> 21536 bytes cv6/temp.c | 1 - 5 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 cv6/a_station.o create mode 100644 cv6/main.o create mode 100755 cv6/station delete mode 100644 cv6/temp.c diff --git a/cv6/a_station.c b/cv6/a_station.c index 8f659d6..4086faa 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -10,24 +10,84 @@ struct station* create_station(){ } void destroy_station(struct station* station){ + if (!station) return; + + for (int i = 0; i < station->track_count; ++i) { + struct car* current = station->tracks[i]; + while (current) { + struct car* temp = current; + current = current->next; + free(temp); + } + } + free(station->tracks); + free(station); } int select_track(struct station* station, const char* target){ - return 0; + int sum = 0; + while (*target) { + sum += *target++; + } + return sum % station->track_count; } void add_target_capacity(struct station* station,const char* target, int capacity){ + int index = select_track(station, target); + struct car* current = station->tracks[index]; + + while (current) { + if (strcmp(current->value, target) == 0) { + current->capacity += capacity; + return; + } + current = current->next; + } + + struct car* new_car = (struct car*)malloc(sizeof(struct car)); + if (!new_car) return; + + strncpy(new_car->value, target, TARGET_SIZE - 1); + new_car->value[TARGET_SIZE - 1] = '\0'; // Ensure null termination + new_car->capacity = capacity; + new_car->next = station->tracks[index]; + station->tracks[index] = new_car; } int get_target_capacity(struct station* station,const char* target){ + int index = select_track(station, target); + struct car* current = station->tracks[index]; + + while (current) { + if (strcmp(current->value, target) == 0) { + return current->capacity; + } + current = current->next; + } return 0; } int count_targets(struct station* station){ - return 0; + int count = 0; + for (int i = 0; i < station->track_count; ++i) { + struct car* current = station->tracks[i]; + while (current) { + ++count; + current = current->next; + } + } + return count; } int count_capacity(struct station* station){ - return 0; + int total_capacity = 0; + for (int i = 0; i < station->track_count; ++i) { + struct car* current = station->tracks[i]; + while (current) { + total_capacity += current->capacity; + current = current->next; + } + } + return total_capacity; } diff --git a/cv6/a_station.o b/cv6/a_station.o new file mode 100644 index 0000000000000000000000000000000000000000..eb74371d19db51784aaea0b7a05940b9c339379c GIT binary patch literal 8440 zcmbtZe{5UD9lvMy5~q$6Cuy37WUE8cQVOvXnw6#{ouRmKTR>4EV~kFTW4|N@$FA)6 z+NMjP!(*H4u{A?%AY~e8n*`I)v`tXfvJy6p42_{q6AUIMMH)EAsOW zo=yo*ZL1jLOv5*f`S4MV4`=&|yF}H*V_DYa@_L2=j67ia|xdKbBo6!j!wgaRiM*~2jJmFvei`&)dqhSyHV5=HdBqs z1Q8ah_<&*sZPj%y-_3}lj%8!LuyL=nVHv7I;r(buw)<$H&AbVsE~NH%h~e}X(H6T? zB??qDO%ifeito)zDLhw#7K=|3UmXTAW=h5y~{ zPXGPO{NF|@;6J*|{}y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96{*(m^9Pdz4er^T)FDu};(Ym31 zJQYhj4>)i*Bii^W2VU#I|K`AP|42Inv_7i+ha9-mzC1|b8-Y5qiHk81h~t@Ph8XqK zBaUwu9?P(aYa;X#7a%;Yq5+0WAqZqM;VAEXdv9{!==YnHXH>zzP5503K1+B`!4D99 zRKd59{7D7BlkguXct6q4DEJAY&nWn3h<;VUcar^c3Qi<@L%|;+`eOzEHQ8yT9_JJ1 zt)J+Sf`6arTNM1OL|ga5(z@eb!KM=*J6uQkzE3H312ke1`Is`$fwCjBvSMWc>2Gd8=Ya#=l>|W&9ZhA0hh&;nKeR zju#bqY5xgDewgO@c?C}rKBw4`>-B~r|1in_Q<1-e;#^elEa7e{?lOKd!`2cm=TpXy zH3S>tWKz)btfJbvT5wDCe*@7Q6?`Yrn-zQ?(LD-o5H0`ihwms3pb34%92-ieM>D_^MlI-Z%Bz$;-e4Y$}JT#4Wo3%6RL;i?vd`|UwJ z3zv8+6n%VXG#i`HDZ&4<3xGbZrQF}rT$l#xpOR44+3??a_{xNxAdF}0EWkqw4M5^h zp0D5!h@#>9fVlIWLdF>tKoFYhAO8e~HdXQeRex(4n*iDVH&8u544dk|8?bWu|A7vM z>u6#ze>~Tz`QK8;CO~W+Uq)z;DGn8q4T6k{p`KZVPsX~e&VH)01HdU4|2!>_)W`TS zb~S#i*Q!l`*iXp+-xa1pvINMM^Y5pF^a2`#hW@d3ss2sC(58$NhN3-$ml9~dR~$-G z_Qye{oPIwY_3>A}xIdju>dF2IV9K#mZlgSCI>9os&j5y7#aVMv zWfSQKkZ?3Pe-e5b2IybakCOhP6r^6&e-ZF<>nATdPm><5AC?5EFW>)izELHNmpf?l rG&%TpA=Fj%ahs{{K0qu$_2)?>9F5G`2#S@{f0{08f3zj7fvW#s6mzA( literal 0 HcmV?d00001 diff --git a/cv6/main.o b/cv6/main.o new file mode 100644 index 0000000000000000000000000000000000000000..6a028e74287ddc992771452b97aafbe9053d2e09 GIT binary patch literal 8608 zcmb_hdvH|c760zty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G^>^(wJVhO6DcVl6UI1dX*Xv~sOSPhc z_Wb=&+3WsiUZtpD9XYoYyZy_Mk&3q0*FPH4b)B`??SBfP)&9gxsjcBlw)lGdXrFHY z!4n5@3=&U&e@TB&&91L$4Sx%pa*MrwKc%CNyp4=kNsZ9j{*MsQ*j3Y>d0nW#kEg$b zr@K+x>3;lI*isXS`Q}5F$v7Qw%4!_##VdQq*NOu)N!-}ZKvrH7!yy&*XwkT zvbXC~ENiJy@s+wM()ROBjzqM*hEtWjO^q#A4tLoE+D^0QjbZ-}%D!ADUK!Z!Zy&?{ zD<6;sYjk49uwOHV{jctj2JZK Date: Sat, 9 Nov 2024 21:50:22 +0000 Subject: [PATCH 085/151] Initializacia --- cv7/program.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 523b003..d43bea1 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -20,15 +20,16 @@ struct tree* read_tree(){ return node; } -struct tstruct tree* load_tree() { - struct tree* tree = read_tree(); - - tree->left = load_tree(); - tree->right = load_tree(); - - if (tree->value[0] == "*"){ - re +struct tree* load_tree() { + struct tree* node = read_tree(); + if (!node) { + return NULL; } + if (node->value[0] != '*') { + node->left = load_tree(); + node->right = load_tree(); + } + return node; } void print_tree(struct tree* tree,int offset){ @@ -61,11 +62,3 @@ void count_items(struct tree* tree, int* count){ } } -int main() { - printf("Constructing the tree:\n"); - struct tree* root = test(); - printf("The tree structure:\n"); - print_tree(root, 0); - - return 0; -} From 5f49f0f96749d23d988a9912c236f567415952ce Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 14:42:10 +0000 Subject: [PATCH 086/151] Initializacia --- cv7/program.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cv7/program.c b/cv7/program.c index d43bea1..ffa74e2 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -1,6 +1,7 @@ #include #include #include +#include #define SIZE 100 From ed485b28e3bb1e7a3dbb5416d4f493474b8a5bec Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 14:49:17 +0000 Subject: [PATCH 087/151] Initializacia --- cv7/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index ffa74e2..ffd0948 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -56,7 +56,7 @@ void destroy_tree(struct tree* tree){ void count_items(struct tree* tree, int* count){ if(tree->left == NULL && tree->right == NULL){ - (*count)++ + (*count)++; }else{ count_items(tree->left, count); count_items(tree->right, count); From ad59e5210032a25adfed5e2650dded68861cb5a0 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 14:51:44 +0000 Subject: [PATCH 088/151] Initializacia --- cv7/program.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index ffd0948..b3e0900 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -33,14 +33,14 @@ struct tree* load_tree() { return node; } -void print_tree(struct tree* tree,int offset){ +void print_tree(struct tree* tree, int offset){ for (int i = 0; i < offset; i++){ printf(" "); } - printf("%s",tree->question); + printf("%s", tree->value); if (tree->left){ - print_tree(tree->left,offset +3); - print_tree(tree->right,offset +3); + print_tree(tree->left, offset + 3); + print_tree(tree->right, offset + 3); } } From 13efda128eea76cdeddcd4163121f91fca122d64 Mon Sep 17 00:00:00 2001 From: Anton Date: Sun, 10 Nov 2024 16:08:07 +0100 Subject: [PATCH 089/151] Initializacia --- cv7/main | Bin 0 -> 16584 bytes cv7/program.c | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100755 cv7/main diff --git a/cv7/main b/cv7/main new file mode 100755 index 0000000000000000000000000000000000000000..5baab3b7b98e8cc075c3df6f425ab7bbfd738284 GIT binary patch literal 16584 zcmeHOdu$xV8K1LbVjzi~kbntovV{bNhc9+s4S|%4olDkj9wxEXq$S;~eQW!~JfEO)9&Giz%fAwW!G-6^K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Y1M#v>nd z2ATZl8hQS$#EvfKiQa&V=DciQ==>h(QsQ~8i?71m&(0USI!gtE-tUVrtFv= zASF-Yzh$ORL*}&~RsyE1$1a#>I^?rIt^`a6*-%loWBQ8Ep65MGANO^5wqv(%`0RNe z%9PjdtnYItex~fX{e`A96@6B*Ot}4+{{=D>Kem5PlM<$POV<7Mm;XCRy!PdvlB!G_ zN$5%b^3Omv3m31K`Mm_6yY=fc&y?0B6&`zjZ_!f?5Q+69H_0=85d!MFTt2Ud_#E|^ zsy~fCN^HmN_yb_1!uGsA>RL+LIFBuf`^)xBFN3kyUWAltjig)-J77EJXTX>+E}!SW zl?Ckm{${K4l{&i>Y=4W3$PCq$l9zJdkrMeEQV!o#9p;mOY0A#^=jSi2>$&dIQvQ~& bl=NMnb1s*4X_+yV{n<}Tjrl$UA1nR|NU!uZ literal 0 HcmV?d00001 diff --git a/cv7/program.c b/cv7/program.c index b3e0900..cbda220 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -63,3 +63,21 @@ void count_items(struct tree* tree, int* count){ } } +int main() { + printf("Nacitanie baze pravidiel:\n"); + struct tree* root = load_tree(); + + if (!root) { + printf("Chyba: Nepodarilo sa nacitat bazu pravidiel.\n"); + return 1; + } + + int count = 0; + count_items(root, &count); + printf("Pozna %d druhov ovocia a zeleniny.\n", count); + printf("Strom pre ladenie:\n"); + print_tree(root, 0); + + destroy_tree(root); + return 0; +} From 00d8213551cf348a2cc36efc11ea874d09a2a7ed Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 15:12:57 +0000 Subject: [PATCH 090/151] Initializacia --- cv7/program.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index cbda220..a237407 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -64,9 +64,7 @@ void count_items(struct tree* tree, int* count){ } int main() { - printf("Nacitanie baze pravidiel:\n"); struct tree* root = load_tree(); - if (!root) { printf("Chyba: Nepodarilo sa nacitat bazu pravidiel.\n"); return 1; @@ -75,8 +73,9 @@ int main() { int count = 0; count_items(root, &count); printf("Pozna %d druhov ovocia a zeleniny.\n", count); - printf("Strom pre ladenie:\n"); - print_tree(root, 0); + printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); + + run_tree(root); destroy_tree(root); return 0; From 7a96dc2c179ff634266558e1f1ff10b2cadbe89c Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 15:14:53 +0000 Subject: [PATCH 091/151] Initializacia --- cv7/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index a237407..c363c36 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -75,7 +75,7 @@ int main() { printf("Pozna %d druhov ovocia a zeleniny.\n", count); printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); - run_tree(root); + print_tree(root); destroy_tree(root); return 0; From ea6d529fad064f53da29a6fc8d6fc3f691c92b33 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 15:36:06 +0000 Subject: [PATCH 092/151] Initializacia --- cv7/program.c | 67 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index c363c36..970b30e 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -1,23 +1,26 @@ -#include -#include -#include -#include +#include +#include +#include +#include #define SIZE 100 -struct tree{ +struct tree { char value[SIZE]; struct tree* left; struct tree* right; }; -struct tree* read_tree(){ +struct tree* read_tree() { char buffer[SIZE]; - memset(buffer,0,SIZE); - char* r = fgets(buffer,SIZE,stdin); - assert(r); - struct tree* node = calloc(1,sizeof(struct tree)); - memcpy(node->value,buffer,SIZE); + memset(buffer, 0, SIZE); + char* r = fgets(buffer, SIZE, stdin); + if (!r || buffer[0] == '\n') { + return NULL; + } + buffer[strcspn(buffer, "\n")] = 0; + struct tree* node = calloc(1, sizeof(struct tree)); + strncpy(node->value, buffer, SIZE - 1); return node; } @@ -33,33 +36,47 @@ struct tree* load_tree() { return node; } -void print_tree(struct tree* tree, int offset){ - for (int i = 0; i < offset; i++){ - printf(" "); +void print_tree(struct tree* tree, int offset) { + if (!tree) { + return; } - printf("%s", tree->value); - if (tree->left){ + + if (tree->value[0] == '*') { + printf("Expert z bufetu to vie.\n%s\nKoniec\n", tree->value + 1); + return; + } + + printf("%s\n", tree->value); + + char response; + if (scanf(" %c", &response) != 1 || (response != 'a' && response != 'n')) { + printf("Nespravny vstup. Koniec.\n"); + return; + } + + if (response == 'a') { print_tree(tree->left, offset + 3); + } else { print_tree(tree->right, offset + 3); } } -void destroy_tree(struct tree* tree){ - if(tree->left != NULL){ +void destroy_tree(struct tree* tree) { + if (tree->left != NULL) { destroy_tree(tree->left); } - if(tree->right != NULL){ + if (tree->right != NULL) { destroy_tree(tree->right); } free(tree); } -void count_items(struct tree* tree, int* count){ - if(tree->left == NULL && tree->right == NULL){ +void count_items(struct tree* tree, int* count) { + if (tree->left == NULL && tree->right == NULL) { (*count)++; - }else{ - count_items(tree->left, count); - count_items(tree->right, count); + } else { + count_items(tree->left, count); + count_items(tree->right, count); } } @@ -75,7 +92,7 @@ int main() { printf("Pozna %d druhov ovocia a zeleniny.\n", count); printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); - print_tree(root); + print_tree(root, 0); destroy_tree(root); return 0; From 9e1a60c36d8c34adad3b99caa8ad0b392b83b800 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 15:38:32 +0000 Subject: [PATCH 093/151] Initializacia --- cv7/program.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 970b30e..2b9e617 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -36,13 +36,14 @@ struct tree* load_tree() { return node; } -void print_tree(struct tree* tree, int offset) { +void run_tree(struct tree* tree) { if (!tree) { return; } if (tree->value[0] == '*') { printf("Expert z bufetu to vie.\n%s\nKoniec\n", tree->value + 1); + printf("*"); return; } @@ -55,9 +56,9 @@ void print_tree(struct tree* tree, int offset) { } if (response == 'a') { - print_tree(tree->left, offset + 3); + run_tree(tree->left); } else { - print_tree(tree->right, offset + 3); + run_tree(tree->right); } } @@ -92,7 +93,7 @@ int main() { printf("Pozna %d druhov ovocia a zeleniny.\n", count); printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); - print_tree(root, 0); + run_tree(root); destroy_tree(root); return 0; From 9ba09a9a3a9cb09248383b3e16ec51ca6fb31c57 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 15:40:39 +0000 Subject: [PATCH 094/151] Initializacia --- cv7/program.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 2b9e617..491f52f 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -42,8 +42,7 @@ void run_tree(struct tree* tree) { } if (tree->value[0] == '*') { - printf("Expert z bufetu to vie.\n%s\nKoniec\n", tree->value + 1); - printf("*"); + printf("Expert z bufetu to vie.\n*%s\nKoniec\n", tree->value + 1); return; } From 7f3b45475686e84aedcd316cf7cc785fbeef2785 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 15:43:02 +0000 Subject: [PATCH 095/151] Initializacia --- cv7/program.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index 491f52f..31ed927 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -42,7 +42,7 @@ void run_tree(struct tree* tree) { } if (tree->value[0] == '*') { - printf("Expert z bufetu to vie.\n*%s\nKoniec\n", tree->value + 1); + printf("*%s\nKoniec\n", tree->value + 1); return; } @@ -89,6 +89,7 @@ int main() { int count = 0; count_items(root, &count); + printf("Expert z bufetu to vie.\n"); printf("Pozna %d druhov ovocia a zeleniny.\n", count); printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); From a7794811d7b794a09163a948e7291a72c1422f0b Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 15:43:59 +0000 Subject: [PATCH 096/151] Initializacia --- cv7/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index 31ed927..b18b7b2 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -50,7 +50,7 @@ void run_tree(struct tree* tree) { char response; if (scanf(" %c", &response) != 1 || (response != 'a' && response != 'n')) { - printf("Nespravny vstup. Koniec.\n"); + printf("Nerozumiem\n"); return; } From f9bc3d6d6e39885334f7dfafebc4a92e4ff8250b Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 15:51:00 +0000 Subject: [PATCH 097/151] Initializacia --- cv7/program.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index b18b7b2..72fed70 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -49,10 +49,14 @@ void run_tree(struct tree* tree) { printf("%s\n", tree->value); char response; - if (scanf(" %c", &response) != 1 || (response != 'a' && response != 'n')) { + if (scanf(" %c", &response) != 1) { + printf("Koniec vstupu\n"); + return; + if else(response != 'a' && response != 'n'){ printf("Nerozumiem\n"); return; } + } if (response == 'a') { run_tree(tree->left); From cda4f030d6b84e6f57456d958274b326469a8f4e Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 15:51:54 +0000 Subject: [PATCH 098/151] Initializacia --- cv7/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index 72fed70..2549acb 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -52,7 +52,7 @@ void run_tree(struct tree* tree) { if (scanf(" %c", &response) != 1) { printf("Koniec vstupu\n"); return; - if else(response != 'a' && response != 'n'){ + else if(response != 'a' && response != 'n'){ printf("Nerozumiem\n"); return; } From 1b9c8f4a2eb09e657f8732017fd70a7e99563d80 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 15:53:15 +0000 Subject: [PATCH 099/151] Initializacia --- cv7/program.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 2549acb..bbb96d5 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -52,11 +52,10 @@ void run_tree(struct tree* tree) { if (scanf(" %c", &response) != 1) { printf("Koniec vstupu\n"); return; - else if(response != 'a' && response != 'n'){ + } else if (response != 'a' && response != 'n') { printf("Nerozumiem\n"); return; } - } if (response == 'a') { run_tree(tree->left); From e94c43f798674960c6836a81173ebfa7c2245468 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 15:54:09 +0000 Subject: [PATCH 100/151] Initializacia --- cv7/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index bbb96d5..cd0c7bd 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -87,7 +87,7 @@ int main() { struct tree* root = load_tree(); if (!root) { printf("Chyba: Nepodarilo sa nacitat bazu pravidiel.\n"); - return 1; + return 0; } int count = 0; From 57556018ea5ef7bfb395f9f392fd4050525f942c Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 15:55:33 +0000 Subject: [PATCH 101/151] Initializacia --- cv7/program.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index cd0c7bd..266a371 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -85,14 +85,14 @@ void count_items(struct tree* tree, int* count) { int main() { struct tree* root = load_tree(); + printf("Expert z bufetu to vie.\n"); if (!root) { - printf("Chyba: Nepodarilo sa nacitat bazu pravidiel.\n"); + printf("Chybna databaza\n"); return 0; } int count = 0; count_items(root, &count); - printf("Expert z bufetu to vie.\n"); printf("Pozna %d druhov ovocia a zeleniny.\n", count); printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); From 8109d836ab3ffa9744d0e2a7991cb711d86bdfbc Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 15:59:31 +0000 Subject: [PATCH 102/151] Initializacia --- cv7/program.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 266a371..ce7a8a8 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -1,6 +1,5 @@ #include #include -#include #include #define SIZE 100 @@ -11,6 +10,8 @@ struct tree { struct tree* right; }; +int error_flag = 0; + struct tree* read_tree() { char buffer[SIZE]; memset(buffer, 0, SIZE); @@ -20,6 +21,11 @@ struct tree* read_tree() { } buffer[strcspn(buffer, "\n")] = 0; struct tree* node = calloc(1, sizeof(struct tree)); + if (buffer[0] == '*') { + if (strlen(buffer) <= 1) { + error_flag = 1; + } + } strncpy(node->value, buffer, SIZE - 1); return node; } @@ -29,7 +35,7 @@ struct tree* load_tree() { if (!node) { return NULL; } - if (node->value[0] != '*') { + if (error_flag || node->value[0] != '*') { node->left = load_tree(); node->right = load_tree(); } @@ -65,16 +71,18 @@ void run_tree(struct tree* tree) { } void destroy_tree(struct tree* tree) { - if (tree->left != NULL) { - destroy_tree(tree->left); - } - if (tree->right != NULL) { - destroy_tree(tree->right); + if (!tree) { + return; } + destroy_tree(tree->left); + destroy_tree(tree->right); free(tree); } void count_items(struct tree* tree, int* count) { + if (!tree) { + return; + } if (tree->left == NULL && tree->right == NULL) { (*count)++; } else { @@ -86,8 +94,9 @@ void count_items(struct tree* tree, int* count) { int main() { struct tree* root = load_tree(); printf("Expert z bufetu to vie.\n"); - if (!root) { + if (!root || error_flag) { printf("Chybna databaza\n"); + destroy_tree(root); return 0; } From bdb10349f2af75105386d06c0f9b4b2b8fa644e7 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 16:02:46 +0000 Subject: [PATCH 103/151] Initializacia --- cv7/program.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index ce7a8a8..6261790 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -20,12 +20,12 @@ struct tree* read_tree() { return NULL; } buffer[strcspn(buffer, "\n")] = 0; - struct tree* node = calloc(1, sizeof(struct tree)); - if (buffer[0] == '*') { - if (strlen(buffer) <= 1) { - error_flag = 1; - } + + if (buffer[0] == '*' && buffer[1] == ' ') { + error_flag = 1; // Invalid format if there's a space after '*' } + + struct tree* node = calloc(1, sizeof(struct tree)); strncpy(node->value, buffer, SIZE - 1); return node; } From f256260acafe10b79dcbfabb906c6a76db50be1c Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 16:12:30 +0000 Subject: [PATCH 104/151] Initializacia --- cv7/program.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 6261790..1394895 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -21,10 +21,6 @@ struct tree* read_tree() { } buffer[strcspn(buffer, "\n")] = 0; - if (buffer[0] == '*' && buffer[1] == ' ') { - error_flag = 1; // Invalid format if there's a space after '*' - } - struct tree* node = calloc(1, sizeof(struct tree)); strncpy(node->value, buffer, SIZE - 1); return node; @@ -35,7 +31,7 @@ struct tree* load_tree() { if (!node) { return NULL; } - if (error_flag || node->value[0] != '*') { + if (node->value[0] != '*') { node->left = load_tree(); node->right = load_tree(); } @@ -55,11 +51,8 @@ void run_tree(struct tree* tree) { printf("%s\n", tree->value); char response; - if (scanf(" %c", &response) != 1) { - printf("Koniec vstupu\n"); - return; - } else if (response != 'a' && response != 'n') { - printf("Nerozumiem\n"); + if (scanf(" %c", &response) != 1 || (response != 'a' && response != 'n')) { + error_flag = 1; return; } @@ -94,9 +87,8 @@ void count_items(struct tree* tree, int* count) { int main() { struct tree* root = load_tree(); printf("Expert z bufetu to vie.\n"); - if (!root || error_flag) { + if (!root) { printf("Chybna databaza\n"); - destroy_tree(root); return 0; } @@ -107,6 +99,10 @@ int main() { run_tree(root); + if (error_flag) { + printf("Chybna databaza\n"); + } + destroy_tree(root); return 0; } From 9f4c3725473824f2b6f9f3c97ba5fdc13df8386a Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 16:16:10 +0000 Subject: [PATCH 105/151] Initializacia --- cv7/program.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 1394895..0f33b8b 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -51,9 +51,11 @@ void run_tree(struct tree* tree) { printf("%s\n", tree->value); char response; - if (scanf(" %c", &response) != 1 || (response != 'a' && response != 'n')) { - error_flag = 1; + if (scanf(" %c", &response) != 1) { + printf("Chybna databaza\n"); return; + } else if (response != 'a' && response != 'n'){ + printf("Nerozumiem\n"); } if (response == 'a') { @@ -99,10 +101,6 @@ int main() { run_tree(root); - if (error_flag) { - printf("Chybna databaza\n"); - } - destroy_tree(root); return 0; } From 8509c1119ce210a87dd657a3a1d02304e8bda4d2 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 16:17:12 +0000 Subject: [PATCH 106/151] Initializacia --- cv7/program.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cv7/program.c b/cv7/program.c index 0f33b8b..d618bfd 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -56,6 +56,7 @@ void run_tree(struct tree* tree) { return; } else if (response != 'a' && response != 'n'){ printf("Nerozumiem\n"); + return; } if (response == 'a') { From ef2e4486204f478d423e775a2cae82cf0ce020df Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 16:20:02 +0000 Subject: [PATCH 107/151] Initializacia --- cv7/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index d618bfd..4521557 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -52,7 +52,7 @@ void run_tree(struct tree* tree) { char response; if (scanf(" %c", &response) != 1) { - printf("Chybna databaza\n"); + printf("Koniec vstupu\n"); return; } else if (response != 'a' && response != 'n'){ printf("Nerozumiem\n"); From 3d40f833d61ba468a2d20cf2a828dc12e2c553dc Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 16:23:37 +0000 Subject: [PATCH 108/151] Initializacia --- cv7/program.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 4521557..5f06f21 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -54,11 +54,16 @@ void run_tree(struct tree* tree) { if (scanf(" %c", &response) != 1) { printf("Koniec vstupu\n"); return; - } else if (response != 'a' && response != 'n'){ - printf("Nerozumiem\n"); + }else if (response != 'a' && response != 'n') { + if (feof(stdin)) { + printf("Chybna databaza\n"); + } else { + printf("Nerozumiem\n"); + } return; } + if (response == 'a') { run_tree(tree->left); } else { From c015a633492d91fea7cfe18fe322aa8c38f68637 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sun, 10 Nov 2024 16:31:51 +0000 Subject: [PATCH 109/151] Initializacia --- cv7/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index 5f06f21..9ef112d 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -55,7 +55,7 @@ void run_tree(struct tree* tree) { printf("Koniec vstupu\n"); return; }else if (response != 'a' && response != 'n') { - if (feof(stdin)) { + if (scanf(" %c", &response) != 1) { printf("Chybna databaza\n"); } else { printf("Nerozumiem\n"); From 72e5b20347189c73c68d8ed1c2c29d1274461e38 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 12:09:54 +0000 Subject: [PATCH 110/151] Initializacia --- cv7/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index 9ef112d..5f06f21 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -55,7 +55,7 @@ void run_tree(struct tree* tree) { printf("Koniec vstupu\n"); return; }else if (response != 'a' && response != 'n') { - if (scanf(" %c", &response) != 1) { + if (feof(stdin)) { printf("Chybna databaza\n"); } else { printf("Nerozumiem\n"); From 2b3c70feacf0df737d3b54ded91aa21e636af10b Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 12:20:05 +0000 Subject: [PATCH 111/151] Initializacia --- cv7/program.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 5f06f21..cb99ef6 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -29,15 +29,18 @@ struct tree* read_tree() { struct tree* load_tree() { struct tree* node = read_tree(); if (!node) { + error_flag = 1; return NULL; } if (node->value[0] != '*') { node->left = load_tree(); + if (error_flag) return node; node->right = load_tree(); } return node; } + void run_tree(struct tree* tree) { if (!tree) { return; @@ -55,11 +58,7 @@ void run_tree(struct tree* tree) { printf("Koniec vstupu\n"); return; }else if (response != 'a' && response != 'n') { - if (feof(stdin)) { - printf("Chybna databaza\n"); - } else { - printf("Nerozumiem\n"); - } + printf("Nerozumiem\n"); return; } @@ -95,8 +94,9 @@ void count_items(struct tree* tree, int* count) { int main() { struct tree* root = load_tree(); printf("Expert z bufetu to vie.\n"); - if (!root) { + if (!root || error_flag) { printf("Chybna databaza\n"); + destroy_tree(root); return 0; } @@ -106,7 +106,7 @@ int main() { printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); run_tree(root); - destroy_tree(root); return 0; } + From 2da0b7a3e5cf2192573382ce44c769ba19dac965 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 12:23:34 +0000 Subject: [PATCH 112/151] Initializacia --- cv7/program.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index cb99ef6..266a371 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -1,5 +1,6 @@ #include #include +#include #include #define SIZE 100 @@ -10,8 +11,6 @@ struct tree { struct tree* right; }; -int error_flag = 0; - struct tree* read_tree() { char buffer[SIZE]; memset(buffer, 0, SIZE); @@ -20,7 +19,6 @@ struct tree* read_tree() { return NULL; } buffer[strcspn(buffer, "\n")] = 0; - struct tree* node = calloc(1, sizeof(struct tree)); strncpy(node->value, buffer, SIZE - 1); return node; @@ -29,18 +27,15 @@ struct tree* read_tree() { struct tree* load_tree() { struct tree* node = read_tree(); if (!node) { - error_flag = 1; return NULL; } if (node->value[0] != '*') { node->left = load_tree(); - if (error_flag) return node; node->right = load_tree(); } return node; } - void run_tree(struct tree* tree) { if (!tree) { return; @@ -57,12 +52,11 @@ void run_tree(struct tree* tree) { if (scanf(" %c", &response) != 1) { printf("Koniec vstupu\n"); return; - }else if (response != 'a' && response != 'n') { + } else if (response != 'a' && response != 'n') { printf("Nerozumiem\n"); return; } - if (response == 'a') { run_tree(tree->left); } else { @@ -71,18 +65,16 @@ void run_tree(struct tree* tree) { } void destroy_tree(struct tree* tree) { - if (!tree) { - return; + if (tree->left != NULL) { + destroy_tree(tree->left); + } + if (tree->right != NULL) { + destroy_tree(tree->right); } - destroy_tree(tree->left); - destroy_tree(tree->right); free(tree); } void count_items(struct tree* tree, int* count) { - if (!tree) { - return; - } if (tree->left == NULL && tree->right == NULL) { (*count)++; } else { @@ -94,9 +86,8 @@ void count_items(struct tree* tree, int* count) { int main() { struct tree* root = load_tree(); printf("Expert z bufetu to vie.\n"); - if (!root || error_flag) { + if (!root) { printf("Chybna databaza\n"); - destroy_tree(root); return 0; } @@ -106,7 +97,7 @@ int main() { printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); run_tree(root); + destroy_tree(root); return 0; } - From b701fb7fdcf5b19750ab030d473fcc394f97e154 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 12:47:48 +0000 Subject: [PATCH 113/151] Initializacia --- cv7/program.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cv7/program.c b/cv7/program.c index 266a371..5b330c1 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -32,10 +32,16 @@ struct tree* load_tree() { if (node->value[0] != '*') { node->left = load_tree(); node->right = load_tree(); + + if (!node->left || !node->right) { + destroy_tree(node); + return NULL; + } } return node; } + void run_tree(struct tree* tree) { if (!tree) { return; From 5501d3b44c891bcbbc25e446e332cd6a570aa414 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 12:50:45 +0000 Subject: [PATCH 114/151] Initializacia --- cv7/program.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 5b330c1..9b3f929 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -13,23 +13,28 @@ struct tree { struct tree* read_tree() { char buffer[SIZE]; - memset(buffer, 0, SIZE); - char* r = fgets(buffer, SIZE, stdin); - if (!r || buffer[0] == '\n') { + if (!fgets(buffer, SIZE, stdin)) { return NULL; } - buffer[strcspn(buffer, "\n")] = 0; + buffer[strcspn(buffer, "\n")] = 0; + + if (buffer[0] == '\0') { + return NULL; + } + struct tree* node = calloc(1, sizeof(struct tree)); strncpy(node->value, buffer, SIZE - 1); return node; } + struct tree* load_tree() { struct tree* node = read_tree(); if (!node) { return NULL; } - if (node->value[0] != '*') { + + if (node->value[0] != '*') { node->left = load_tree(); node->right = load_tree(); @@ -38,10 +43,12 @@ struct tree* load_tree() { return NULL; } } + return node; } + void run_tree(struct tree* tree) { if (!tree) { return; @@ -92,7 +99,8 @@ void count_items(struct tree* tree, int* count) { int main() { struct tree* root = load_tree(); printf("Expert z bufetu to vie.\n"); - if (!root) { + + if (!root) { printf("Chybna databaza\n"); return 0; } @@ -103,7 +111,7 @@ int main() { printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); run_tree(root); - destroy_tree(root); return 0; } + From ee9e324e9ff05ffb0dce076463e2ff397377ce11 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 12:53:51 +0000 Subject: [PATCH 115/151] Initializacia --- cv7/program.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cv7/program.c b/cv7/program.c index 9b3f929..3c7eabe 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -42,6 +42,13 @@ struct tree* load_tree() { destroy_tree(node); return NULL; } + } else { + struct tree* extra = read_tree(); + if (extra) { + free(extra); + destroy_tree(node); + return NULL; + } } return node; @@ -49,6 +56,7 @@ struct tree* load_tree() { + void run_tree(struct tree* tree) { if (!tree) { return; @@ -115,3 +123,4 @@ int main() { return 0; } + From cf685571c59235be81d71bb69a940eda0b9bd1e5 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 12:56:52 +0000 Subject: [PATCH 116/151] Initializacia --- cv7/program.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 3c7eabe..657f883 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -13,21 +13,24 @@ struct tree { struct tree* read_tree() { char buffer[SIZE]; - if (!fgets(buffer, SIZE, stdin)) { - return NULL; + + while (fgets(buffer, SIZE, stdin)) { + buffer[strcspn(buffer, "\n")] = 0; + + if (buffer[0] == '\0') { + continue; + } + + struct tree* node = calloc(1, sizeof(struct tree)); + strncpy(node->value, buffer, SIZE - 1); + return node; } - buffer[strcspn(buffer, "\n")] = 0; - - if (buffer[0] == '\0') { - return NULL; - } - - struct tree* node = calloc(1, sizeof(struct tree)); - strncpy(node->value, buffer, SIZE - 1); - return node; + + return NULL; } + struct tree* load_tree() { struct tree* node = read_tree(); if (!node) { @@ -38,14 +41,7 @@ struct tree* load_tree() { node->left = load_tree(); node->right = load_tree(); - if (!node->left || !node->right) { - destroy_tree(node); - return NULL; - } - } else { - struct tree* extra = read_tree(); - if (extra) { - free(extra); + if (!node->left || !node->right) { destroy_tree(node); return NULL; } @@ -57,6 +53,7 @@ struct tree* load_tree() { + void run_tree(struct tree* tree) { if (!tree) { return; From d2efa5d900af6170a24b0589c2205dd08c04169a Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 13:00:16 +0000 Subject: [PATCH 117/151] Initializacia --- cv7/program.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 657f883..551776a 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -37,11 +37,18 @@ struct tree* load_tree() { return NULL; } - if (node->value[0] != '*') { + if (node->value[0] != '*') { node->left = load_tree(); node->right = load_tree(); - if (!node->left || !node->right) { + if (!node->left || !node->right) { + destroy_tree(node); + return NULL; + } + } else { + struct tree* extra = read_tree(); + if (extra) { + free(extra); destroy_tree(node); return NULL; } @@ -54,6 +61,7 @@ struct tree* load_tree() { + void run_tree(struct tree* tree) { if (!tree) { return; @@ -105,7 +113,7 @@ int main() { struct tree* root = load_tree(); printf("Expert z bufetu to vie.\n"); - if (!root) { + if (!root) { printf("Chybna databaza\n"); return 0; } @@ -121,3 +129,4 @@ int main() { } + From 724940804f4cc0fefc3eef232553b0b10d80187d Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 13:01:20 +0000 Subject: [PATCH 118/151] Initializacia --- cv7/program.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 551776a..657f883 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -37,18 +37,11 @@ struct tree* load_tree() { return NULL; } - if (node->value[0] != '*') { + if (node->value[0] != '*') { node->left = load_tree(); node->right = load_tree(); - if (!node->left || !node->right) { - destroy_tree(node); - return NULL; - } - } else { - struct tree* extra = read_tree(); - if (extra) { - free(extra); + if (!node->left || !node->right) { destroy_tree(node); return NULL; } @@ -61,7 +54,6 @@ struct tree* load_tree() { - void run_tree(struct tree* tree) { if (!tree) { return; @@ -113,7 +105,7 @@ int main() { struct tree* root = load_tree(); printf("Expert z bufetu to vie.\n"); - if (!root) { + if (!root) { printf("Chybna databaza\n"); return 0; } @@ -129,4 +121,3 @@ int main() { } - From 55853490b25834957e6408113794b8250c993f89 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 15:48:07 +0000 Subject: [PATCH 119/151] Initializacia --- cv7/program.c | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 657f883..266a371 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -13,47 +13,29 @@ struct tree { struct tree* read_tree() { char buffer[SIZE]; - - while (fgets(buffer, SIZE, stdin)) { - buffer[strcspn(buffer, "\n")] = 0; - - if (buffer[0] == '\0') { - continue; - } - - struct tree* node = calloc(1, sizeof(struct tree)); - strncpy(node->value, buffer, SIZE - 1); - return node; + memset(buffer, 0, SIZE); + char* r = fgets(buffer, SIZE, stdin); + if (!r || buffer[0] == '\n') { + return NULL; } - - return NULL; + buffer[strcspn(buffer, "\n")] = 0; + struct tree* node = calloc(1, sizeof(struct tree)); + strncpy(node->value, buffer, SIZE - 1); + return node; } - - struct tree* load_tree() { struct tree* node = read_tree(); if (!node) { return NULL; } - - if (node->value[0] != '*') { + if (node->value[0] != '*') { node->left = load_tree(); node->right = load_tree(); - - if (!node->left || !node->right) { - destroy_tree(node); - return NULL; - } } - return node; } - - - - void run_tree(struct tree* tree) { if (!tree) { return; @@ -104,8 +86,7 @@ void count_items(struct tree* tree, int* count) { int main() { struct tree* root = load_tree(); printf("Expert z bufetu to vie.\n"); - - if (!root) { + if (!root) { printf("Chybna databaza\n"); return 0; } @@ -116,8 +97,7 @@ int main() { printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); run_tree(root); + destroy_tree(root); return 0; } - - From 36f9d01893e420881bab9b09385881d6b68e7aa3 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 15:56:01 +0000 Subject: [PATCH 120/151] Initializacia --- cv7/program.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 266a371..de4cd79 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -29,9 +29,13 @@ struct tree* load_tree() { if (!node) { return NULL; } - if (node->value[0] != '*') { + + if (node->value[0] != '*') { node->left = load_tree(); node->right = load_tree(); + } else { + node->left = NULL; + node->right = NULL; } return node; } @@ -42,7 +46,7 @@ void run_tree(struct tree* tree) { } if (tree->value[0] == '*') { - printf("*%s\nKoniec\n", tree->value + 1); + printf("%s\nKoniec\n", tree->value + 1); return; } @@ -78,8 +82,8 @@ void count_items(struct tree* tree, int* count) { if (tree->left == NULL && tree->right == NULL) { (*count)++; } else { - count_items(tree->left, count); - count_items(tree->right, count); + if (tree->left) count_items(tree->left, count); + if (tree->right) count_items(tree->right, count); } } From 8d07713b655a67f563a4ca3435c72f1ba3f4cfd6 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 16:02:43 +0000 Subject: [PATCH 121/151] Initializacia --- cv7/program.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index de4cd79..4ce932f 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -1,6 +1,5 @@ #include #include -#include #include #define SIZE 100 @@ -18,7 +17,7 @@ struct tree* read_tree() { if (!r || buffer[0] == '\n') { return NULL; } - buffer[strcspn(buffer, "\n")] = 0; + buffer[strcspn(buffer, "\n")] = 0; struct tree* node = calloc(1, sizeof(struct tree)); strncpy(node->value, buffer, SIZE - 1); return node; @@ -30,15 +29,11 @@ struct tree* load_tree() { return NULL; } - if (node->value[0] != '*') { + if (node->value[0] != '*') { node->left = load_tree(); node->right = load_tree(); - } else { - node->left = NULL; - node->right = NULL; } - return node; -} + return node; void run_tree(struct tree* tree) { if (!tree) { @@ -46,11 +41,11 @@ void run_tree(struct tree* tree) { } if (tree->value[0] == '*') { - printf("%s\nKoniec\n", tree->value + 1); + printf("%s\nKoniec\n", tree->value + 1); return; } - printf("%s\n", tree->value); + printf("%s\n", tree->value); char response; if (scanf(" %c", &response) != 1) { @@ -79,7 +74,9 @@ void destroy_tree(struct tree* tree) { } void count_items(struct tree* tree, int* count) { - if (tree->left == NULL && tree->right == NULL) { + if (!tree) return; + + if (tree->value[0] == '*') { (*count)++; } else { if (tree->left) count_items(tree->left, count); @@ -90,6 +87,7 @@ void count_items(struct tree* tree, int* count) { int main() { struct tree* root = load_tree(); printf("Expert z bufetu to vie.\n"); + if (!root) { printf("Chybna databaza\n"); return 0; From 8a8974112a0c26858d64977ece3e06f7bf76d514 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 16:03:36 +0000 Subject: [PATCH 122/151] Initializacia --- cv7/program.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cv7/program.c b/cv7/program.c index 4ce932f..ef8b955 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -34,6 +34,7 @@ struct tree* load_tree() { node->right = load_tree(); } return node; +} void run_tree(struct tree* tree) { if (!tree) { From 5001be183c02545fe47c972325ca4773eacca607 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 16:05:03 +0000 Subject: [PATCH 123/151] Initializacia --- cv7/program.c | 53 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index ef8b955..53b94ec 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -1,5 +1,6 @@ #include #include +#include #include #define SIZE 100 @@ -12,41 +13,56 @@ struct tree { struct tree* read_tree() { char buffer[SIZE]; - memset(buffer, 0, SIZE); - char* r = fgets(buffer, SIZE, stdin); - if (!r || buffer[0] == '\n') { - return NULL; + + while (fgets(buffer, SIZE, stdin)) { + buffer[strcspn(buffer, "\n")] = 0; + + if (buffer[0] == '\0') { + continue; + } + + struct tree* node = calloc(1, sizeof(struct tree)); + strncpy(node->value, buffer, SIZE - 1); + return node; } - buffer[strcspn(buffer, "\n")] = 0; - struct tree* node = calloc(1, sizeof(struct tree)); - strncpy(node->value, buffer, SIZE - 1); - return node; + + return NULL; } + + struct tree* load_tree() { struct tree* node = read_tree(); if (!node) { return NULL; } - if (node->value[0] != '*') { + if (node->value[0] != '*') { node->left = load_tree(); node->right = load_tree(); + } else { + node->left = NULL; + node->right = NULL; } - return node; + + return node; } + + + + void run_tree(struct tree* tree) { if (!tree) { return; } if (tree->value[0] == '*') { - printf("%s\nKoniec\n", tree->value + 1); + printf("*%s\nKoniec\n", tree->value + 1); return; } - printf("%s\n", tree->value); + printf("%s\n", tree->value); char response; if (scanf(" %c", &response) != 1) { @@ -75,13 +91,11 @@ void destroy_tree(struct tree* tree) { } void count_items(struct tree* tree, int* count) { - if (!tree) return; - - if (tree->value[0] == '*') { + if (tree->left == NULL && tree->right == NULL) { (*count)++; } else { - if (tree->left) count_items(tree->left, count); - if (tree->right) count_items(tree->right, count); + count_items(tree->left, count); + count_items(tree->right, count); } } @@ -89,7 +103,7 @@ int main() { struct tree* root = load_tree(); printf("Expert z bufetu to vie.\n"); - if (!root) { + if (!root) { printf("Chybna databaza\n"); return 0; } @@ -100,7 +114,8 @@ int main() { printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); run_tree(root); - destroy_tree(root); return 0; } + + From 6ec70db7995b9b897dd1fc0a3f62eb465a8de69d Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 16:09:51 +0000 Subject: [PATCH 124/151] Initializacia --- cv7/program.c | 60 ++++++++++++++++++++++----------------------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 53b94ec..0c69c32 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -1,6 +1,5 @@ #include #include -#include #include #define SIZE 100 @@ -13,52 +12,41 @@ struct tree { struct tree* read_tree() { char buffer[SIZE]; - - while (fgets(buffer, SIZE, stdin)) { - buffer[strcspn(buffer, "\n")] = 0; - - if (buffer[0] == '\0') { - continue; - } - - struct tree* node = calloc(1, sizeof(struct tree)); - strncpy(node->value, buffer, SIZE - 1); - return node; + memset(buffer, 0, SIZE); + + if (!fgets(buffer, SIZE, stdin) || buffer[0] == '\n') { + return NULL; } - - return NULL; + + buffer[strcspn(buffer, "\n")] = 0; + + struct tree* node = (struct tree*)calloc(1, sizeof(struct tree)); + strncpy(node->value, buffer, SIZE - 1); + + return node; } - - struct tree* load_tree() { struct tree* node = read_tree(); if (!node) { return NULL; } - if (node->value[0] != '*') { + if (node->value[0] != '*') { node->left = load_tree(); node->right = load_tree(); - } else { - node->left = NULL; - node->right = NULL; } - + return node; } - - - - void run_tree(struct tree* tree) { if (!tree) { return; } if (tree->value[0] == '*') { - printf("*%s\nKoniec\n", tree->value + 1); + printf("%s\nKoniec\n", tree->value + 1); return; } @@ -81,16 +69,20 @@ void run_tree(struct tree* tree) { } void destroy_tree(struct tree* tree) { - if (tree->left != NULL) { - destroy_tree(tree->left); - } - if (tree->right != NULL) { - destroy_tree(tree->right); + if (!tree) { + return; } + + destroy_tree(tree->left); + destroy_tree(tree->right); free(tree); } void count_items(struct tree* tree, int* count) { + if (!tree) { + return; + } + if (tree->left == NULL && tree->right == NULL) { (*count)++; } else { @@ -101,9 +93,10 @@ void count_items(struct tree* tree, int* count) { int main() { struct tree* root = load_tree(); + printf("Expert z bufetu to vie.\n"); - if (!root) { + if (!root) { printf("Chybna databaza\n"); return 0; } @@ -114,8 +107,7 @@ int main() { printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); run_tree(root); + destroy_tree(root); return 0; } - - From 3ecf1439928c98912f7e6cb3390363d1efdd7322 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 16:12:28 +0000 Subject: [PATCH 125/151] Initializacia --- cv7/program.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 0c69c32..8ebd22a 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -13,16 +13,13 @@ struct tree { struct tree* read_tree() { char buffer[SIZE]; memset(buffer, 0, SIZE); - - if (!fgets(buffer, SIZE, stdin) || buffer[0] == '\n') { + char* r = fgets(buffer, SIZE, stdin); + if (!r || buffer[0] == '\n') { return NULL; } - - buffer[strcspn(buffer, "\n")] = 0; - - struct tree* node = (struct tree*)calloc(1, sizeof(struct tree)); + buffer[strcspn(buffer, "\n")] = 0; + struct tree* node = calloc(1, sizeof(struct tree)); strncpy(node->value, buffer, SIZE - 1); - return node; } From f533cab35cb1d2f0300e6fbb3b5f4edc7185a7e7 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 16:13:45 +0000 Subject: [PATCH 126/151] Initializacia --- cv7/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index 8ebd22a..6cfe83f 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -43,7 +43,7 @@ void run_tree(struct tree* tree) { } if (tree->value[0] == '*') { - printf("%s\nKoniec\n", tree->value + 1); + printf("*%s\nKoniec\n", tree->value + 1); return; } From e14c23ba016c568b5ffd6c8d93a95d2cfcaeefec Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 16:14:39 +0000 Subject: [PATCH 127/151] Initializacia --- cv7/program.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 6cfe83f..266a371 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -1,5 +1,6 @@ #include #include +#include #include #define SIZE 100 @@ -17,7 +18,7 @@ struct tree* read_tree() { if (!r || buffer[0] == '\n') { return NULL; } - buffer[strcspn(buffer, "\n")] = 0; + buffer[strcspn(buffer, "\n")] = 0; struct tree* node = calloc(1, sizeof(struct tree)); strncpy(node->value, buffer, SIZE - 1); return node; @@ -28,12 +29,10 @@ struct tree* load_tree() { if (!node) { return NULL; } - if (node->value[0] != '*') { node->left = load_tree(); node->right = load_tree(); } - return node; } @@ -66,20 +65,16 @@ void run_tree(struct tree* tree) { } void destroy_tree(struct tree* tree) { - if (!tree) { - return; + if (tree->left != NULL) { + destroy_tree(tree->left); + } + if (tree->right != NULL) { + destroy_tree(tree->right); } - - destroy_tree(tree->left); - destroy_tree(tree->right); free(tree); } void count_items(struct tree* tree, int* count) { - if (!tree) { - return; - } - if (tree->left == NULL && tree->right == NULL) { (*count)++; } else { @@ -90,9 +85,7 @@ void count_items(struct tree* tree, int* count) { int main() { struct tree* root = load_tree(); - printf("Expert z bufetu to vie.\n"); - if (!root) { printf("Chybna databaza\n"); return 0; From 42ef7de47eaaad9f2e5d4babcdf5b08d310931dc Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 16:20:56 +0000 Subject: [PATCH 128/151] Initializacia --- cv7/program.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index 266a371..835db5e 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -42,7 +42,13 @@ void run_tree(struct tree* tree) { } if (tree->value[0] == '*') { - printf("*%s\nKoniec\n", tree->value + 1); + // If the node starts with *, check for children + if (tree->left || tree->right) { + printf("Expert z bufetu to vie.\nChybna databaza\n"); + } else { + // If no children, it's the end of a branch + printf("*%s\nKoniec\n", tree->value + 1); + } return; } @@ -64,6 +70,7 @@ void run_tree(struct tree* tree) { } } + void destroy_tree(struct tree* tree) { if (tree->left != NULL) { destroy_tree(tree->left); From ca43f2f98281f24748ab21ec3474b4dd783ff618 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 16:22:00 +0000 Subject: [PATCH 129/151] Initializacia --- cv7/program.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 835db5e..e7ae045 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -42,13 +42,7 @@ void run_tree(struct tree* tree) { } if (tree->value[0] == '*') { - // If the node starts with *, check for children - if (tree->left || tree->right) { - printf("Expert z bufetu to vie.\nChybna databaza\n"); - } else { - // If no children, it's the end of a branch - printf("*%s\nKoniec\n", tree->value + 1); - } + printf("*%s\nKoniec\n", tree->value + 1); return; } @@ -70,7 +64,6 @@ void run_tree(struct tree* tree) { } } - void destroy_tree(struct tree* tree) { if (tree->left != NULL) { destroy_tree(tree->left); @@ -107,4 +100,4 @@ int main() { destroy_tree(root); return 0; -} +} \ No newline at end of file From 745926af828ac87df09d27ca3526af94d71b2f8f Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 17:55:09 +0000 Subject: [PATCH 130/151] Initializacia --- cv7/program.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index e7ae045..e4fdfe0 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -1,6 +1,5 @@ #include #include -#include #include #define SIZE 100 @@ -42,6 +41,7 @@ void run_tree(struct tree* tree) { } if (tree->value[0] == '*') { + // If it's an answer printf("*%s\nKoniec\n", tree->value + 1); return; } @@ -65,21 +65,21 @@ void run_tree(struct tree* tree) { } void destroy_tree(struct tree* tree) { - if (tree->left != NULL) { + if (tree) { destroy_tree(tree->left); - } - if (tree->right != NULL) { destroy_tree(tree->right); + free(tree); } - free(tree); } void count_items(struct tree* tree, int* count) { - if (tree->left == NULL && tree->right == NULL) { - (*count)++; - } else { - count_items(tree->left, count); - count_items(tree->right, count); + if (tree) { + if (tree->left == NULL && tree->right == NULL) { + (*count)++; + } else { + count_items(tree->left, count); + count_items(tree->right, count); + } } } From dd1da65481730d3581db4d047804fd85c98bf327 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 17:57:20 +0000 Subject: [PATCH 131/151] Initializacia --- cv7/program.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index e4fdfe0..61cc1d4 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -10,31 +10,32 @@ struct tree { struct tree* right; }; +// Function to read a single node from input struct tree* read_tree() { char buffer[SIZE]; - memset(buffer, 0, SIZE); - char* r = fgets(buffer, SIZE, stdin); - if (!r || buffer[0] == '\n') { + if (fgets(buffer, SIZE, stdin) == NULL || buffer[0] == '\n') { return NULL; } - buffer[strcspn(buffer, "\n")] = 0; + buffer[strcspn(buffer, "\n")] = 0; // Remove newline character struct tree* node = calloc(1, sizeof(struct tree)); strncpy(node->value, buffer, SIZE - 1); return node; } +// Function to load the tree structure from input struct tree* load_tree() { struct tree* node = read_tree(); if (!node) { return NULL; } - if (node->value[0] != '*') { + if (node->value[0] != '*') { // Not an answer, so load children node->left = load_tree(); node->right = load_tree(); } return node; } +// Function to run the tree and interact with the user void run_tree(struct tree* tree) { if (!tree) { return; @@ -47,6 +48,7 @@ void run_tree(struct tree* tree) { } printf("%s\n", tree->value); + printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); char response; if (scanf(" %c", &response) != 1) { @@ -64,6 +66,7 @@ void run_tree(struct tree* tree) { } } +// Function to free the memory allocated for the tree void destroy_tree(struct tree* tree) { if (tree) { destroy_tree(tree->left); @@ -72,10 +75,11 @@ void destroy_tree(struct tree* tree) { } } +// Function to count the number of unique items (answers) in the tree void count_items(struct tree* tree, int* count) { if (tree) { if (tree->left == NULL && tree->right == NULL) { - (*count)++; + (*count)++; // It's a leaf node (an answer) } else { count_items(tree->left, count); count_items(tree->right, count); @@ -84,8 +88,9 @@ void count_items(struct tree* tree, int* count) { } int main() { - struct tree* root = load_tree(); printf("Expert z bufetu to vie.\n"); + + struct tree* root = load_tree(); if (!root) { printf("Chybna databaza\n"); return 0; @@ -94,10 +99,8 @@ int main() { int count = 0; count_items(root, &count); printf("Pozna %d druhov ovocia a zeleniny.\n", count); - printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); run_tree(root); - destroy_tree(root); return 0; } \ No newline at end of file From 302f4d4987f9b773256d20d62fc9da002e7b4a13 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 17:59:15 +0000 Subject: [PATCH 132/151] Initializacia --- cv7/program.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index 61cc1d4..c056c10 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -14,7 +14,7 @@ struct tree { struct tree* read_tree() { char buffer[SIZE]; if (fgets(buffer, SIZE, stdin) == NULL || buffer[0] == '\n') { - return NULL; + return NULL; // Return NULL for empty input } buffer[strcspn(buffer, "\n")] = 0; // Remove newline character struct tree* node = calloc(1, sizeof(struct tree)); From b7e46be38d161ae37609c6fbf4b65d6e138182d4 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 18:05:10 +0000 Subject: [PATCH 133/151] Initializacia --- cv7/program.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index c056c10..e14a3aa 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -51,12 +51,14 @@ void run_tree(struct tree* tree) { printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); char response; - if (scanf(" %c", &response) != 1) { - printf("Koniec vstupu\n"); - return; - } else if (response != 'a' && response != 'n') { - printf("Nerozumiem\n"); - return; + while (1) { + // Wait for user input + if (scanf(" %c", &response) != 1 || (response != 'a' && response != 'n')) { + printf("Nerozumiem\n"); + // Re-prompt for input + continue; + } + break; // Valid input received } if (response == 'a') { From 27c63a26ef1ae312e08e23648d0221fd25cfe01f Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 18:29:32 +0000 Subject: [PATCH 134/151] Initializacia --- cv7/program.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index e14a3aa..b8e0cfe 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -10,39 +10,35 @@ struct tree { struct tree* right; }; -// Function to read a single node from input struct tree* read_tree() { char buffer[SIZE]; if (fgets(buffer, SIZE, stdin) == NULL || buffer[0] == '\n') { - return NULL; // Return NULL for empty input + return NULL; } - buffer[strcspn(buffer, "\n")] = 0; // Remove newline character + buffer[strcspn(buffer, "\n")] = 0; struct tree* node = calloc(1, sizeof(struct tree)); strncpy(node->value, buffer, SIZE - 1); return node; } -// Function to load the tree structure from input struct tree* load_tree() { struct tree* node = read_tree(); if (!node) { return NULL; } - if (node->value[0] != '*') { // Not an answer, so load children + if (node->value[0] != '*') { node->left = load_tree(); node->right = load_tree(); } return node; } -// Function to run the tree and interact with the user void run_tree(struct tree* tree) { if (!tree) { return; } if (tree->value[0] == '*') { - // If it's an answer printf("*%s\nKoniec\n", tree->value + 1); return; } @@ -52,13 +48,11 @@ void run_tree(struct tree* tree) { char response; while (1) { - // Wait for user input if (scanf(" %c", &response) != 1 || (response != 'a' && response != 'n')) { printf("Nerozumiem\n"); - // Re-prompt for input continue; } - break; // Valid input received + break; } if (response == 'a') { @@ -68,7 +62,6 @@ void run_tree(struct tree* tree) { } } -// Function to free the memory allocated for the tree void destroy_tree(struct tree* tree) { if (tree) { destroy_tree(tree->left); @@ -77,11 +70,10 @@ void destroy_tree(struct tree* tree) { } } -// Function to count the number of unique items (answers) in the tree void count_items(struct tree* tree, int* count) { if (tree) { if (tree->left == NULL && tree->right == NULL) { - (*count)++; // It's a leaf node (an answer) + (*count)++; } else { count_items(tree->left, count); count_items(tree->right, count); From fe7326837f23b9bc040cd24ced1a3fe64aab58e7 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 19:10:28 +0000 Subject: [PATCH 135/151] Initializacia --- cv7/program.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index b8e0cfe..63ac077 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -38,12 +38,13 @@ void run_tree(struct tree* tree) { return; } + printf("%s\n", tree->value); + if (tree->value[0] == '*') { - printf("*%s\nKoniec\n", tree->value + 1); + printf("Koniec\n"); return; } - printf("%s\n", tree->value); printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); char response; From 0e5b2261b024d3ce15372aea900891a82b813444 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 19:12:14 +0000 Subject: [PATCH 136/151] Initializacia --- cv7/program.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 63ac077..e4fdfe0 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -12,7 +12,9 @@ struct tree { struct tree* read_tree() { char buffer[SIZE]; - if (fgets(buffer, SIZE, stdin) == NULL || buffer[0] == '\n') { + memset(buffer, 0, SIZE); + char* r = fgets(buffer, SIZE, stdin); + if (!r || buffer[0] == '\n') { return NULL; } buffer[strcspn(buffer, "\n")] = 0; @@ -38,22 +40,21 @@ void run_tree(struct tree* tree) { return; } - printf("%s\n", tree->value); - if (tree->value[0] == '*') { - printf("Koniec\n"); + // If it's an answer + printf("*%s\nKoniec\n", tree->value + 1); return; } - printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); + printf("%s\n", tree->value); char response; - while (1) { - if (scanf(" %c", &response) != 1 || (response != 'a' && response != 'n')) { - printf("Nerozumiem\n"); - continue; - } - break; + if (scanf(" %c", &response) != 1) { + printf("Koniec vstupu\n"); + return; + } else if (response != 'a' && response != 'n') { + printf("Nerozumiem\n"); + return; } if (response == 'a') { @@ -83,9 +84,8 @@ void count_items(struct tree* tree, int* count) { } int main() { - printf("Expert z bufetu to vie.\n"); - struct tree* root = load_tree(); + printf("Expert z bufetu to vie.\n"); if (!root) { printf("Chybna databaza\n"); return 0; @@ -94,8 +94,10 @@ int main() { int count = 0; count_items(root, &count); printf("Pozna %d druhov ovocia a zeleniny.\n", count); + printf("Odpovedajte 'a' pre prvu moznost alebo 'n' pre druhu moznost.\n"); run_tree(root); + destroy_tree(root); return 0; } \ No newline at end of file From e548847f2e57f9dbb7d94949003d72b91b182bc8 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 19:15:40 +0000 Subject: [PATCH 137/151] Initializacia --- cv7/program.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index e4fdfe0..0d71563 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -31,6 +31,11 @@ struct tree* load_tree() { if (node->value[0] != '*') { node->left = load_tree(); node->right = load_tree(); + } else if (node->left != NULL || node->right != NULL) { + printf("Expert z bufetu to vie.\n"); + printf("Chybna databaza\n"); + free(node); + return NULL; } return node; } @@ -41,7 +46,6 @@ void run_tree(struct tree* tree) { } if (tree->value[0] == '*') { - // If it's an answer printf("*%s\nKoniec\n", tree->value + 1); return; } @@ -85,12 +89,12 @@ void count_items(struct tree* tree, int* count) { int main() { struct tree* root = load_tree(); - printf("Expert z bufetu to vie.\n"); if (!root) { - printf("Chybna databaza\n"); return 0; } + printf("Expert z bufetu to vie.\n"); + int count = 0; count_items(root, &count); printf("Pozna %d druhov ovocia a zeleniny.\n", count); From 192ea219b45f42ab69f4697066b21ce1814f667a Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 19:19:17 +0000 Subject: [PATCH 138/151] Initializacia --- cv7/program.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index 0d71563..7d216e0 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -33,7 +33,6 @@ struct tree* load_tree() { node->right = load_tree(); } else if (node->left != NULL || node->right != NULL) { printf("Expert z bufetu to vie.\n"); - printf("Chybna databaza\n"); free(node); return NULL; } @@ -89,12 +88,22 @@ void count_items(struct tree* tree, int* count) { int main() { struct tree* root = load_tree(); + if (!root) { + printf("Chybna databaza\n"); return 0; } printf("Expert z bufetu to vie.\n"); + // Check if the input is empty after loading the tree + char buffer[SIZE]; + if (fgets(buffer, SIZE, stdin) == NULL || buffer[0] == '\n') { + printf("Chybna databaza\n"); + destroy_tree(root); + return 0; + } + int count = 0; count_items(root, &count); printf("Pozna %d druhov ovocia a zeleniny.\n", count); From 3f0bc73577be262bb65297141b152420bda0c819 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 19:22:34 +0000 Subject: [PATCH 139/151] Initializacia --- cv7/program.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/cv7/program.c b/cv7/program.c index 7d216e0..44d7cff 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -96,14 +96,6 @@ int main() { printf("Expert z bufetu to vie.\n"); - // Check if the input is empty after loading the tree - char buffer[SIZE]; - if (fgets(buffer, SIZE, stdin) == NULL || buffer[0] == '\n') { - printf("Chybna databaza\n"); - destroy_tree(root); - return 0; - } - int count = 0; count_items(root, &count); printf("Pozna %d druhov ovocia a zeleniny.\n", count); From 68b117c30456e5df4378269fa30c9d9940758610 Mon Sep 17 00:00:00 2001 From: Kozar Date: Tue, 12 Nov 2024 19:24:07 +0000 Subject: [PATCH 140/151] Initializacia --- cv7/program.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cv7/program.c b/cv7/program.c index 44d7cff..4ba61f1 100644 --- a/cv7/program.c +++ b/cv7/program.c @@ -89,12 +89,13 @@ void count_items(struct tree* tree, int* count) { int main() { struct tree* root = load_tree(); + printf("Expert z bufetu to vie.\n"); + if (!root) { printf("Chybna databaza\n"); return 0; } - printf("Expert z bufetu to vie.\n"); int count = 0; count_items(root, &count); From 746d776383a84d8f3d64f567c68d65a6d44e4f9d Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 18 Nov 2024 14:43:38 +0100 Subject: [PATCH 141/151] Initializcia --- cv4/Makefile | 30 +++++++++++++---- cv4/a_train.c | 14 ++++---- cv4/main | Bin 0 -> 21376 bytes cv4/main.c | 88 ++++++++++++++++++++++++++++++++++++++++++++------ 4 files changed, 107 insertions(+), 25 deletions(-) create mode 100755 cv4/main diff --git a/cv4/Makefile b/cv4/Makefile index 3c2c463..f7793c7 100644 --- a/cv4/Makefile +++ b/cv4/Makefile @@ -1,13 +1,29 @@ -CFLAGS= -std=c99 -g -Wall +# Compiler and flags +CC = gcc +CFLAGS = -std=c99 -g -Wall -all: train +# Source files and object files +SRCS = main.c a_train.c +OBJS = $(SRCS:.c=.o) +# Target executable +TARGET = main + +# Default rule to build the executable +all: $(TARGET) + +# Rule to link object files and create the executable +$(TARGET): $(OBJS) + $(CC) $(OBJS) -o $(TARGET) + +# Rule to compile .c files into .o files %.o: %.c - gcc -c -o $@ $< $(CFLAGS) - -train: main.o a_train.o - gcc main.o a_train.o -o train + $(CC) $(CFLAGS) -c $< -o $@ +# Clean up generated files clean: - rm *.o train + rm -f $(OBJS) $(TARGET) + +# Phony targets (targets that are not actual files) +.PHONY: all clean diff --git a/cv4/a_train.c b/cv4/a_train.c index c117b1a..f078efd 100644 --- a/cv4/a_train.c +++ b/cv4/a_train.c @@ -4,19 +4,18 @@ #include struct car* add_car(struct car* first, const char* target) { - struct car* last = first; struct car* newcar = calloc(1, sizeof(struct car)); strcpy(newcar->value, target); + newcar->next = NULL; - if (last != NULL) { - struct car* current = last; + if (first == NULL) { + first = newcar; + } else { + struct car* current = first; while (current->next != NULL) { current = current->next; } current->next = newcar; - } else { - last = newcar; - return last; } return first; @@ -25,7 +24,7 @@ struct car* add_car(struct car* first, const char* target) { void print_train(struct car* first) { if(first != NULL){ struct car* current = first; - while(current->next != NULL){ + while(current != NULL){ printf("%s\n", current->value); current = current->next; } @@ -41,7 +40,6 @@ void cancel_train(struct car* first) { } } - struct car* clear_train(struct car* first, const char* target) { if (first == NULL) { return NULL; diff --git a/cv4/main b/cv4/main new file mode 100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Ghz45MKuNlUz zHfaXadsrymhj)eW_L8r0Y6<%0K-3H-62SpXGw?zY?nHPc%M7Rc`Uaq4!%Rq~azy1V zX>#;7%?;buZEiQ)Z(VO<$N%~}Z(X;!qYY*-y)fGYk{ejRjhQ!Z+H%vnP3D#j8*Xpk zZf;+9)24Ql-v#~Z^8@_*0?tn#WV!edLGHbG`VSF^TWwa8?D9_^$lJD>V$$ama)kJt zAcvAWkFvx}f+C12@~KYt;|f`|7C9r#5~z6c2w!%{q494%(AlKxo8f}`5gu`oQ#{1U@T1EXrL(zeJsMH*(4J)O|vVRltu8_WA1k(vbI;C()i$m zYHa!v#FU?R$o;lOR-HF5bt%St$$>u1ssK|70V67hDXf*~XFj}FXZbLZ@nJ66ZzWO# zHd0qQiZ8W9!;-Y_rVdO%dl(mwV1mhf;ei;65D?R3&e?@2KfUE>M@;Y%R&S6LWUjwA z#eCdNAF{rlI8e$Ytq}92Xm01@9l)1}^X}lYBJ!e%gkeo#!iKndgoetas9;|d#)LXz z&wRLS`)F3^3tL_39!LgbJ-Egt8jW?wRX*6&g?XaF@UZ`AAu% zPmkg#MRCxSR+X>Ta}|7#glx$f{||vjYokhEt%oY8;-~yqathKzc3Nvy_;D$y;8t0- z(|_gCA!Mjcls<0^Vv+*VhyYBL@2vkP!6*Hjq?}q$R#2@!lRm}FssAKs6cc4Xdmonf zW9r}bXJ-<5xBv;W7`_v6%e;^gI&?fw= z56X6Z=9kiq0;+P94W*}WdUu*=s(dw{E}urFDLqBLb{hT1rT+J`1B=jb>Mxr{fAb>M5Y~6#PS}ulNc+?iV>)wXr9qr)Y#bs>oR< z{6gZayx^|^O3yx2|5Nu*dM@OsB3C>rS0LYZ7 +#include +#include -// Testovaci subor pre vlak -int main(){ +int main() { struct car* train = NULL; - train = add_car(train,"Presov"); - train = add_car(train,"Bratislava"); - train = add_car(train,"Levoca"); - train = add_car(train,"Spiska Nova Ves"); - print_train(train); - train = clear_train(train,"Levoca"); - print_train(train); - cancel_train(train); + int choice; + char station[100]; + + while (1) { + printf("\nMenu:\n"); + printf("1. Add station\n"); + printf("2. Remove a station\n"); + printf("3. Print route\n"); + printf("4. Cancel train\n"); + printf("5. Exit\n"); + printf("Enter your choice: "); + scanf("%d", &choice); + getchar(); + + switch(choice) { + case 1: + while (1) { + printf("Enter the station name to add (or press Enter to stop): "); + fgets(station, sizeof(station), stdin); + station[strcspn(station, "\n")] = '\0'; // Remove newline character + + if (station[0] == '\0') { + break; // Exit the loop if input is empty + } + + train = add_car(train, station); + printf("Station '%s' added to the train.\n", station); + } + break; + case 2: + while (1) { + printf("Enter the station name to clear (or press Enter to stop): "); + fgets(station, sizeof(station), stdin); + station[strcspn(station, "\n")] = '\0'; // Remove newline character + + if (station[0] == '\0') { + break; // Exit the loop if input is empty + } + + struct car* temp = train; + int found = 0; + while (temp != NULL) { + if (strcmp(temp->value, station) == 0) { + found = 1; + break; + } + temp = temp->next; + } + + if (found) { + train = clear_train(train, station); + printf("Station '%s' deleted from the train.\n", station); + } else { + printf("Station '%s' does not exist in the train.\n", station); + } + } + break; + case 3: + printf("\nRoute List:\n"); + print_train(train); + break; + case 4: + printf("\nCanceling the train...\n"); + cancel_train(train); + train = NULL; + break; + case 5: + printf("Exiting program...\n"); + cancel_train(train); + return 0; + default: + printf("Invalid choice, please try again.\n"); + } + } return 0; } + From 4130c229607144f2ac3ed4d002b3a3fb025bad26 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 18 Nov 2024 17:43:08 +0100 Subject: [PATCH 142/151] Initializacia --- cv6/a_station.c | 167 ++++++++++++++---------------------------------- 1 file changed, 48 insertions(+), 119 deletions(-) diff --git a/cv6/a_station.c b/cv6/a_station.c index a86b4df..c117b1a 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -1,143 +1,72 @@ +#include "a_train.h" #include -#include "a_station.h" #include #include -struct station* create_station(){ - struct station* station = (struct station*)calloc(1,sizeof(struct station)); - station->tracks = (struct car**)calloc(STATION_SIZE, sizeof(struct car*)); - station->track_count = STATION_SIZE; - return station; -} +struct car* add_car(struct car* first, const char* target) { + struct car* last = first; + struct car* newcar = calloc(1, sizeof(struct car)); + strcpy(newcar->value, target); -void destroy_station(struct station* station){ -<<<<<<< HEAD - if (!station) return; - - for (int i = 0; i < station->track_count; ++i) { -======= - for (int i = 0; i < station->track_count; i++) { ->>>>>>> 2f4bf820c1657cb30626d282fd1907d4428dd2e7 - struct car* current = station->tracks[i]; - while (current) { - struct car* temp = current; + if (last != NULL) { + struct car* current = last; + while (current->next != NULL) { current = current->next; - free(temp); } + current->next = newcar; + } else { + last = newcar; + return last; } - free(station->tracks); - free(station); + + return first; } -int select_track(struct station* station, const char* target){ -<<<<<<< HEAD - int sum = 0; - while (*target) { - sum += *target++; -======= - size_t length = strlen(target); - int sum = 0; - for (size_t i = 0; i < length; i++) { - sum += target[i]; ->>>>>>> 2f4bf820c1657cb30626d282fd1907d4428dd2e7 +void print_train(struct car* first) { + if(first != NULL){ + struct car* current = first; + while(current->next != NULL){ + printf("%s\n", current->value); + current = current->next; + } } - return sum % station->track_count; } -void add_target_capacity(struct station* station,const char* target, int capacity){ -<<<<<<< HEAD - int index = select_track(station, target); - struct car* current = station->tracks[index]; -======= - int track = select_track(station, target); - struct car* current = station->tracks[track]; ->>>>>>> 2f4bf820c1657cb30626d282fd1907d4428dd2e7 - - while (current) { - if (strcmp(current->value, target) == 0) { - current->capacity += capacity; - return; - } +void cancel_train(struct car* first) { + struct car* current = first; + while(first != NULL){ current = current->next; + free(first); + first = current; + } +} + + +struct car* clear_train(struct car* first, const char* target) { + if (first == NULL) { + return NULL; } -<<<<<<< HEAD - struct car* new_car = (struct car*)malloc(sizeof(struct car)); - if (!new_car) return; + struct car* current = first; + struct car* previous = NULL; - strncpy(new_car->value, target, TARGET_SIZE - 1); - new_car->value[TARGET_SIZE - 1] = '\0'; // Ensure null termination - new_car->capacity = capacity; - new_car->next = station->tracks[index]; - station->tracks[index] = new_car; -} + while (current != NULL && strcmp(current->value, target) == 0) { + struct car* temp = current; + first = current->next; + current = first; + free(temp); + } -int get_target_capacity(struct station* station,const char* target){ - int index = select_track(station, target); - struct car* current = station->tracks[index]; -======= - struct car* new_car = malloc(sizeof(struct car)); - strncpy(new_car->value, target, TARGET_SIZE - 1); - new_car->value[TARGET_SIZE - 1] = '\0'; - new_car->capacity = capacity; - new_car->next = station->tracks[track]; - station->tracks[track] = new_car; -} - -int get_target_capacity(struct station* station, const char* target) { - int track = select_track(station, target); - struct car* current = station->tracks[track]; ->>>>>>> 2f4bf820c1657cb30626d282fd1907d4428dd2e7 - - while (current) { + while (current != NULL) { if (strcmp(current->value, target) == 0) { - return current->capacity; - } - current = current->next; - } -<<<<<<< HEAD - return 0; -} - -int count_targets(struct station* station){ - int count = 0; - for (int i = 0; i < station->track_count; ++i) { - struct car* current = station->tracks[i]; - while (current) { - ++count; -======= - - return 0; -} - -int count_targets(struct station* station) { - int count = 0; - for (int i = 0; i < station->track_count; i++) { - struct car* current = station->tracks[i]; - while (current) { - count++; ->>>>>>> 2f4bf820c1657cb30626d282fd1907d4428dd2e7 + previous->next = current->next; + free(current); + current = previous->next; + } else { + previous = current; current = current->next; } } - return count; -} -<<<<<<< HEAD -int count_capacity(struct station* station){ - int total_capacity = 0; - for (int i = 0; i < station->track_count; ++i) { -======= -int count_capacity(struct station* station) { - int total_capacity = 0; - for (int i = 0; i < station->track_count; i++) { ->>>>>>> 2f4bf820c1657cb30626d282fd1907d4428dd2e7 - struct car* current = station->tracks[i]; - while (current) { - total_capacity += current->capacity; - current = current->next; - } - } - return total_capacity; + return first; } - From 57490613d201fe61894b4e68de2c9f98eff205c0 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 18 Nov 2024 17:45:15 +0100 Subject: [PATCH 143/151] Initializacia --- cv6/a_station.c | 125 ++++++++++++++++++++++++++++-------------------- 1 file changed, 73 insertions(+), 52 deletions(-) diff --git a/cv6/a_station.c b/cv6/a_station.c index c117b1a..4fec864 100644 --- a/cv6/a_station.c +++ b/cv6/a_station.c @@ -1,72 +1,93 @@ -#include "a_train.h" #include +#include "a_station.h" #include #include -struct car* add_car(struct car* first, const char* target) { - struct car* last = first; - struct car* newcar = calloc(1, sizeof(struct car)); - strcpy(newcar->value, target); - - if (last != NULL) { - struct car* current = last; - while (current->next != NULL) { - current = current->next; - } - current->next = newcar; - } else { - last = newcar; - return last; - } - - return first; +struct station* create_station(){ + struct station* station = (struct station*)calloc(1,sizeof(struct station)); + station->tracks = (struct car**)calloc(STATION_SIZE, sizeof(struct car*)); + station->track_count = STATION_SIZE; + return station; } -void print_train(struct car* first) { - if(first != NULL){ - struct car* current = first; - while(current->next != NULL){ - printf("%s\n", current->value); +void destroy_station(struct station* station){ + for (int i = 0; i < station->track_count; i++) { + struct car* current = station->tracks[i]; + while (current) { + struct car* temp = current; current = current->next; + free(temp); } } + free(station->tracks); + free(station); } -void cancel_train(struct car* first) { - struct car* current = first; - while(first != NULL){ - current = current->next; - free(first); - first = current; +int select_track(struct station* station, const char* target){ + size_t length = strlen(target); + int sum = 0; + for (size_t i = 0; i < length; i++) { + sum += target[i]; } + return sum % station->track_count; } +void add_target_capacity(struct station* station,const char* target, int capacity){ + int track = select_track(station, target); + struct car* current = station->tracks[track]; -struct car* clear_train(struct car* first, const char* target) { - if (first == NULL) { - return NULL; - } - - struct car* current = first; - struct car* previous = NULL; - - while (current != NULL && strcmp(current->value, target) == 0) { - struct car* temp = current; - first = current->next; - current = first; - free(temp); - } - - while (current != NULL) { + while (current) { if (strcmp(current->value, target) == 0) { - previous->next = current->next; - free(current); - current = previous->next; - } else { - previous = current; + current->capacity += capacity; + return; + } + current = current->next; + } + + struct car* new_car = malloc(sizeof(struct car)); + strncpy(new_car->value, target, TARGET_SIZE - 1); + new_car->value[TARGET_SIZE - 1] = '\0'; + new_car->capacity = capacity; + new_car->next = station->tracks[track]; + station->tracks[track] = new_car; +} + +int get_target_capacity(struct station* station, const char* target) { + int track = select_track(station, target); + struct car* current = station->tracks[track]; + + while (current) { + if (strcmp(current->value, target) == 0) { + return current->capacity; + } + current = current->next; + } + + return 0; +} + +int count_targets(struct station* station) { + int count = 0; + for (int i = 0; i < station->track_count; i++) { + struct car* current = station->tracks[i]; + while (current) { + count++; current = current->next; } } - - return first; + return count; } + +int count_capacity(struct station* station) { + int total_capacity = 0; + for (int i = 0; i < station->track_count; i++) { + struct car* current = station->tracks[i]; + while (current) { + total_capacity += current->capacity; + current = current->next; + } + } + return total_capacity; +} + + From cc577a088c6d2f3e5e18c4676f50488ecf251cc1 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 18 Nov 2024 18:12:47 +0100 Subject: [PATCH 144/151] Initializacia --- cv6/a_station.o | Bin 8440 -> 0 bytes cv6/main.c | 77 ++++++++++++++++++++++++++++-------------------- cv6/main.o | Bin 8608 -> 0 bytes cv6/station | Bin 21536 -> 22784 bytes 4 files changed, 45 insertions(+), 32 deletions(-) delete mode 100644 cv6/a_station.o delete mode 100644 cv6/main.o diff --git a/cv6/a_station.o b/cv6/a_station.o deleted file mode 100644 index eb74371d19db51784aaea0b7a05940b9c339379c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8440 zcmbtZe{5UD9lvMy5~q$6Cuy37WUE8cQVOvXnw6#{ouRmKTR>4EV~kFTW4|N@$FA)6 z+NMjP!(*H4u{A?%AY~e8n*`I)v`tXfvJy6p42_{q6AUIMMH)EAsOW zo=yo*ZL1jLOv5*f`S4MV4`=&|yF}H*V_DYa@_L2=j67ia|xdKbBo6!j!wgaRiM*~2jJmFvei`&)dqhSyHV5=HdBqs z1Q8ah_<&*sZPj%y-_3}lj%8!LuyL=nVHv7I;r(buw)<$H&AbVsE~NH%h~e}X(H6T? zB??qDO%ifeito)zDLhw#7K=|3UmXTAW=h5y~{ zPXGPO{NF|@;6J*|{}yQv`#lc-O$cbc-0A!{V$igiUr6V@*OGG)N^c*|v1@ujq_f>e z*$Qfh*iM+7*q`mf5NDWmqymeHs%+P>2=8n&ptXw*IZ;)6o3gVH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9?P(aYa;X#7a%;Yq5+0WAqZqM;VAEXdv9{!==YnHXH>zzP5503K1+B`!4D99 zRKd59{7D7BlkguXct6q4DEJAY&nWn3h<;VUcar^c3Qi<@L%|;+`eOzEHQ8yT9_JJ1 zt)J+Sf`6arTNM1OL|ga5(z@eb!KM=*J6uQkzE3H312ke1`Is`$fwCjBvSMWc>2Gd8=Ya#=l>|W&9ZhA0hh&;nKeR zju#bqY5xgDewgO@c?C}rKBw4`>-B~r|1in_Q<1-e;#^elEa7e{?lOKd!`2cm=TpXy zH3S>tWKz)btfJbvT5wDCe*@7Q6?`Yrn-zQ?(LD-o5H0`ihwms3pb34%92-ieM>D_^MlI-Z%Bz$;-e4Y$}JT#4Wo3%6RL;i?vd`|UwJ z3zv8+6n%VXG#i`HDZ&4<3xGbZrQF}rT$l#xpOR44+3??a_{xNxAdF}0EWkqw4M5^h zp0D5!h@#>9fVlIWLdF>tKoFYhAO8e~HdXQeRex(4n*iDVH&8u544dk|8?bWu|A7vM z>u6#ze>~Tz`QK8;CO~W+Uq)z;DGn8q4T6k{p`KZVPsX~e&VH)01HdU4|2!>_)W`TS zb~S#i*Q!l`*iXp+-xa1pvINMM^Y5pF^a2`#hW@d3ss2sC(58$NhN3-$ml9~dR~$-G z_Qye{oPIwY_3>A}xIdju>dF2IV9K#mZlgSCI>9os&j5y7#aVMv zWfSQKkZ?3Pe-e5b2IybakCOhP6r^6&e-ZF<>nATdPm><5AC?5EFW>)izELHNmpf?l rG&%TpA=Fj%ahs{{K0qu$_2)?>9F5G`2#S@{f0{08f3zj7fvW#s6mzA( diff --git a/cv6/main.c b/cv6/main.c index a909625..dee0e23 100644 --- a/cv6/main.c +++ b/cv6/main.c @@ -1,41 +1,54 @@ #include "a_station.h" #include -#include #include +#include -void print_station(struct station* station){ - // Vypise celu stanicu - printf("station>>>\n"); - // Prechadza vsetky trate - for (int i = 0 ; i< station->track_count; i++){ - struct car* start = station->tracks[i]; - struct car* this = start; - // Prechadza vsetky vozne - while(this != NULL){ - printf("%s %d -> ",this->value,this->capacity); - this=this->next; +#define MAX_INPUT 100 + +void test_station(struct station* station) { + char station_name[MAX_INPUT]; + int capacity; + + printf("Enter station name and capacity (or 'exit' to stop):\n"); + + while (1) { + printf("Station name: "); + if (!fgets(station_name, MAX_INPUT, stdin)) break; + + // Remove trailing newline + station_name[strcspn(station_name, "\n")] = '\0'; + + if (strcmp(station_name, "exit") == 0) break; + + printf("Capacity: "); + if (scanf("%d", &capacity) != 1) { + printf("Invalid input. Try again.\n"); + while (getchar() != '\n'); // Clear input buffer + continue; } - printf("NULL\n"); + + // Clear input buffer + while (getchar() != '\n'); + + add_target_capacity(station, station_name, capacity); + + int track = select_track(station, station_name); + printf("Track for %s: %d\n", station_name, track); + + int current_capacity = get_target_capacity(station, station_name); + printf("Current capacity to %s: %d\n\n", station_name, current_capacity); } - printf("<<U7y*^XFg|K)tIo8=8F8@Y51e*dtj^eTzI(pi zyC0jjfApKl{m%KF-#Op=wfRnX+gDXZVInDPBg<<7W$gTtyxh&jZdT70vAF^w8A15Q(@H>%gARC^G9FCkg?};dHMzTN)Uk1x% z$S-{y0_jq=w+XYz%&B~&=P(2h$4%MpX5>ev_FiI{b9owPOoitZV7-&=_H~8l_8gGR zht9s7tMUDF*wV<%G2a(od=ZOey(^oc9IR6N@toUq5R7@Pxj<_x(AE`b-33~tKdegaQXpj?#P7_R6X#V0KdVm8Jk0TF3;~lWyZ==jt1L(7nLpVa`JkJe zoyI8;nR#7I+lWA%SvR$9T8v0%%_AiH(vwryx& zRw8P!O}c3f>%mPEmYq&Sb)oOD6Z)8mKyPYHpDdv4FcYTEBAF4xG$BA5%CwUD7*LJL zgqa#tLBr&O* z6YO^Vo?*_|l!+xq5^1(Q6-(=E`-D@wclxF$uT@9&G;34+zTJRvys{icN3JfL z0}e`~ znD-(0)FG%|Q-eq={8g|8h-hb&%1y|`70DLjr(|38CCK^^#SinM%7cdQMG!-%p97|1 zAHm)aNjs%fpjMAcY0OcM2x0|mKwMd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y7Kns{nV^0BA##c)i&c{OZ3#2dV)c~?lR>r4 zUrEyED)PkggA{ozbU0#D5Ly+A#fnXy|G|ksIGqec;g~)~vEgnQhGU69HXR9zr9qyp z{GLW03!@`E>XIrD*qu(RYKVoeeQ_5E;6oUCK+qR5M*ZwX-ufy3^B(#2pi#(}FWuRW zePpYln?9Fjz|hi#u3);Yz!ZziG>ww)#?pc+_o{H9>wC7 z`NEwEgpe?kl9Ii6=aE+WLQN3?$WoDbkPH;o5zjE6sHP97uPq6ZkaQ%(d>LA>`sk>G zc2W!sWe;5@ zYx}Xj%cN~A_ZkFiiOoKW`Iw4^wURXV`n;wYw4SiW*XvXby;@O0yZv8-kJnM@G%1RH zeypL6U#R5v`UkuE?&DCk+TruFk=4V#p`z5a^L=q4`ZRNJ3Wfi&z_iaNf%{hw3z ztCgO9Uap}_HJI!vXLkE1!6Oyz-#m}2^SOSH04k!``~Nt&R(r3q)39HfnR~rV(D2JP z`%6loq1Mw5G_BzYoBfayXh?Ev(RLbs4?=7G^>^(wJVhO6DcVl6UI1dX*Xv~sOSPhc z_Wb=&+3WsiUZtpD9XYoYyZy_Mk&3q0*FPH4b)B`??SBfP)&9gxsjcBlw)lGdXrFHY z!4n5@3=&U&e@TB&&91L$4Sx%pa*MrwKc%CNyp4=kNsZ9j{*MsQ*j3Y>d0nW#kEg$b zr@K+x>3;lI*isXS`Q}5F$v7Qw%4!_##VdQq*NOu)N!-}ZKvrH7!yy&*XwkT zvbXC~ENiJy@s+wM()ROBjzqM*hEtWjO^q#A4tLoE+D^0QjbZ-}%D!ADUK!Z!Zy&?{ zD<6;sYjk49uwOHV{jctj2JZK Date: Tue, 19 Nov 2024 14:01:00 +0100 Subject: [PATCH 145/151] Initializacia --- cv4/main | Bin 21376 -> 0 bytes cv6/main.c | 3 +-- cv6/station | Bin 22784 -> 0 bytes cv7/program.c | 4 ++-- 4 files changed, 3 insertions(+), 4 deletions(-) delete mode 100755 cv4/main delete mode 100755 cv6/station diff --git a/cv4/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,7 +32,7 @@ struct tree* load_tree() { node->left = load_tree(); node->right = load_tree(); } else if (node->left != NULL || node->right != NULL) { - printf("Expert z bufetu to vie.\n"); + printf("Chybna databaza\n"); free(node); return NULL; } @@ -106,4 +106,4 @@ int main() { destroy_tree(root); return 0; -} \ No newline at end of file +} From 05f7a22103ef8a5c2ee3e3345754a77980b4c0fc Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 19 Nov 2024 15:23:54 +0100 Subject: [PATCH 146/151] Initializacia --- a4/program.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 a4/program.c diff --git a/a4/program.c b/a4/program.c new file mode 100644 index 0000000..899e543 --- /dev/null +++ b/a4/program.c @@ -0,0 +1,34 @@ +#include +#include + +int is_heap(int* arr, int size ){ + for(int i = 0; i < size; i++){ + int l = i * 2 + 1; + int r = i * 2 + 2; + } + + if (left < size && arr[i] < arr[left]){ + return 0; + } + + if (right < size && arr[i] < arr[right]){ + return 0; + } + return 1; +} + +int main() { + int arr[] = 100; + int size = 0; + + while (scanf("%d", &num) != EOF){ + arr[size++] = num; + } + + if (!is_heap(arr, size)){ + printf("Nie je kopa."); + } + + return 0; +} + From 63895a7c6d45619d132d03a8f6ce5a3e5f5e1f36 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 19 Nov 2024 15:26:03 +0100 Subject: [PATCH 147/151] Initializacia --- a4/program.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/a4/program.c b/a4/program.c index 899e543..407e014 100644 --- a/a4/program.c +++ b/a4/program.c @@ -7,11 +7,11 @@ int is_heap(int* arr, int size ){ int r = i * 2 + 2; } - if (left < size && arr[i] < arr[left]){ + if (l < size && arr[i] < arr[l]){ return 0; } - if (right < size && arr[i] < arr[right]){ + if (r < size && arr[i] < arr[r]){ return 0; } return 1; From f003e6d1c99d7fe487bc41ab18fbc1d936e7145b Mon Sep 17 00:00:00 2001 From: Kozar Date: Sat, 14 Dec 2024 13:19:43 +0000 Subject: [PATCH 148/151] Add sk1/compressor.h --- sk1/compressor.h | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sk1/compressor.h diff --git a/sk1/compressor.h b/sk1/compressor.h new file mode 100644 index 0000000..e69de29 From d2f149a18a6a9405d0efc58bb0f244278f2c96d0 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sat, 14 Dec 2024 13:20:04 +0000 Subject: [PATCH 149/151] Update sk1/compressor.h --- sk1/compressor.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sk1/compressor.h b/sk1/compressor.h index e69de29..84e3f83 100644 --- a/sk1/compressor.h +++ b/sk1/compressor.h @@ -0,0 +1,10 @@ +#ifndef COMPRESSOR_H +#define COMPRESSOR_H + +#define BUFFER_SIZE 1024 +#define LZ78_DICT_SIZE 256 + +int compress(const char* input_file_name, const char* output_file_name); +int decompress(const char* input_file_name, const char* output_file_name); + +#endif // COMPRESSOR_H From a64589724ea5211e7cb6936b4b8a102711f59053 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sat, 14 Dec 2024 13:20:21 +0000 Subject: [PATCH 150/151] Add sk1/compressor.c --- sk1/compressor.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 sk1/compressor.c diff --git a/sk1/compressor.c b/sk1/compressor.c new file mode 100644 index 0000000..e69de29 From cac4809a6428a9689a3ba1ca772973bd65400ee2 Mon Sep 17 00:00:00 2001 From: Kozar Date: Sat, 14 Dec 2024 13:20:39 +0000 Subject: [PATCH 151/151] Update sk1/compressor.c --- sk1/compressor.c | 136 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) diff --git a/sk1/compressor.c b/sk1/compressor.c index e69de29..408ad14 100644 --- a/sk1/compressor.c +++ b/sk1/compressor.c @@ -0,0 +1,136 @@ +#include +#include +#include +#include + +#define BUFFER_SIZE 1024 +#define LZ78_DICT_SIZE 256 + +// Function prototypes +int compress(const char* input_file_name, const char* output_file_name); +int decompress(const char* input_file_name, const char* output_file_name); +void lz78_compress(FILE* in, FILE* out); +void lz78_decompress(FILE* in, FILE* out); + +void print_usage() { + printf("Usage:\n"); + printf(" ./compressor -c infile outfile Compress infile into outfile\n"); + printf(" ./compressor -d compressed uncompressed Decompress compressed into uncompressed\n"); +} + +int main(int argc, char* argv[]) { + if (argc != 4) { + print_usage(); + return 1; + } + + const char* mode = argv[1]; + const char* infile = argv[2]; + const char* outfile = argv[3]; + + if (strcmp(mode, "-c") == 0) { + return compress(infile, outfile); + } else if (strcmp(mode, "-d") == 0) { + return decompress(infile, outfile); + } else { + print_usage(); + return 1; + } +} + +int compress(const char* input_file_name, const char* output_file_name) { + FILE* input_file = fopen(input_file_name, "rb"); + if (!input_file) { + perror("Error opening input file"); + return -1; + } + + FILE* output_file = fopen(output_file_name, "wb"); + if (!output_file) { + perror("Error opening output file"); + fclose(input_file); + return -1; + } + + lz78_compress(input_file, output_file); + + fclose(input_file); + fclose(output_file); + + printf("File compressed successfully.\n"); + return 0; +} + +int decompress(const char* input_file_name, const char* output_file_name) { + FILE* input_file = fopen(input_file_name, "rb"); + if (!input_file) { + perror("Error opening input file"); + return -1; + } + + FILE* output_file = fopen(output_file_name, "wb"); + if (!output_file) { + perror("Error opening output file"); + fclose(input_file); + return -1; + } + + lz78_decompress(input_file, output_file); + + fclose(input_file); + fclose(output_file); + + printf("File decompressed successfully.\n"); + return 0; +} + +// LZ78 compression +struct dict { + int index; + struct dict* characters[LZ78_DICT_SIZE]; +}; + +void delete_dict(struct dict* tree) { + if (!tree) { + return; + } + for (int i = 0; i < LZ78_DICT_SIZE; i++) { + delete_dict(tree->characters[i]); + } + free(tree); +} + +void lz78_compress(FILE* in, FILE* out) { + struct dict* root = calloc(1, sizeof(struct dict)); + struct dict* current = root; + int index = 1; + int c; + + while ((c = fgetc(in)) != EOF) { + if (current->characters[c]) { + current = current->characters[c]; + } else { + current->characters[c] = calloc(1, sizeof(struct dict)); + current->characters[c]->index = index++; + fprintf(out, "%d-%c\n", current->index, c); + current = root; + } + } + + delete_dict(root); +} + +// LZ78 decompression +void lz78_decompress(FILE* in, FILE* out) { + char buffer[LZ78_DICT_SIZE][BUFFER_SIZE] = {""}; + int index; + char c; + + while (fscanf(in, "%d-%c\n", &index, &c) == 2) { + if (index > 0) { + fprintf(out, "%s", buffer[index]); + } + fputc(c, out); + snprintf(buffer[index], BUFFER_SIZE, "%s%c", buffer[index], c); + } +}