2024-10-01 12:01:13 +00:00
|
|
|
#include <stdio.h>
|
2024-10-02 12:27:38 +00:00
|
|
|
#include <string.h>
|
2024-10-02 18:26:34 +00:00
|
|
|
#include <ctype.h>
|
2024-10-02 12:27:38 +00:00
|
|
|
|
2024-10-02 18:26:34 +00:00
|
|
|
#define MAX_INPUT_LENGTH 100
|
|
|
|
|
|
|
|
// 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'}
|
2024-10-02 12:33:13 +00:00
|
|
|
};
|
2024-10-02 12:27:38 +00:00
|
|
|
|
2024-10-01 12:01:13 +00:00
|
|
|
int main() {
|
2024-10-02 18:26:34 +00:00
|
|
|
char ingredient[MAX_INPUT_LENGTH];
|
|
|
|
char menu_item[MAX_INPUT_LENGTH];
|
2024-10-02 12:27:38 +00:00
|
|
|
int count = 0;
|
|
|
|
|
2024-10-02 18:26:34 +00:00
|
|
|
// Read the ingredient to be searched
|
|
|
|
printf("Zadaj hladanu surovinu: ");
|
|
|
|
fgets(ingredient, MAX_INPUT_LENGTH, stdin);
|
|
|
|
ingredient[strcspn(ingredient, "\n")] = 0; // Remove newline character
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
|
// 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;
|
2024-10-02 12:27:38 +00:00
|
|
|
|
2024-10-02 18:26:34 +00:00
|
|
|
// Search for the ingredient in the name
|
|
|
|
if (strstr(name_hack3r, ingredient) != NULL) {
|
|
|
|
printf("%s\n", menu_item);
|
|
|
|
count++;
|
2024-10-02 17:32:07 +00:00
|
|
|
}
|
2024-10-02 16:59:35 +00:00
|
|
|
}
|
|
|
|
|
2024-10-02 18:26:34 +00:00
|
|
|
// Display the count of successful searches
|
2024-10-02 12:33:13 +00:00
|
|
|
printf("Nacitanych %d poloziek.\n", count);
|
2024-10-02 12:27:38 +00:00
|
|
|
|
2024-10-01 12:01:13 +00:00
|
|
|
return 0;
|
2024-10-02 18:26:34 +00:00
|
|
|
}
|