2024-09-29 08:17:52 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#define MAX_LENGTH 100
|
|
|
|
|
|
|
|
void decode_hacker_script(const char *input, char *output) {
|
|
|
|
int j = 0;
|
|
|
|
for (int i = 0; input[i]; i++) {
|
|
|
|
char c = tolower(input[i]);
|
|
|
|
if (c == 'o' || c == '0') output[j++] = 'o';
|
|
|
|
else if (c == 'i' || c == '1') output[j++] = 'i';
|
|
|
|
else if (c == 'z' || c == '2') output[j++] = 'z';
|
|
|
|
else if (c == 'e' || c == '3') output[j++] = 'e';
|
|
|
|
else if (c == 'a' || c == '4') output[j++] = 'a';
|
|
|
|
else if (c == 's' || c == '5') output[j++] = 's';
|
|
|
|
else if (c == 'b' || c == '6' || c == '8') output[j++] = 'b';
|
|
|
|
else if (c == 't' || c == '7') output[j++] = 't';
|
|
|
|
else if (c == 'q' || c == '9') output[j++] = 'q';
|
|
|
|
else output[j++] = c;
|
|
|
|
}
|
|
|
|
output[j] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
char search_item[MAX_LENGTH], menu_item[MAX_LENGTH], price[MAX_LENGTH];
|
|
|
|
char decoded_item[MAX_LENGTH], decoded_search[MAX_LENGTH];
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
printf("Zadaj hladanu surovinu:\n");
|
|
|
|
scanf("%s", search_item);
|
|
|
|
decode_hacker_script(search_item, decoded_search);
|
2024-09-29 08:26:32 +00:00
|
|
|
|
2024-09-29 08:24:35 +00:00
|
|
|
while (getchar() != '\n');
|
2024-09-29 08:17:52 +00:00
|
|
|
|
2024-09-29 08:22:55 +00:00
|
|
|
printf("Zadaj jedalny listok:\n");
|
2024-09-29 08:17:52 +00:00
|
|
|
|
|
|
|
while (1) {
|
|
|
|
if (fgets(menu_item, sizeof(menu_item), stdin) == NULL || strlen(menu_item) == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
menu_item[strcspn(menu_item, "\n")] = 0;
|
|
|
|
|
|
|
|
if (fgets(price, sizeof(price), stdin) == NULL || strlen(price) == 0) {
|
2024-09-29 08:24:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2024-09-29 08:17:52 +00:00
|
|
|
price[strcspn(price, "\n")] = 0;
|
|
|
|
|
|
|
|
decode_hacker_script(menu_item, decoded_item);
|
2024-09-29 08:35:57 +00:00
|
|
|
count++;
|
2024-09-29 08:17:52 +00:00
|
|
|
|
2024-09-29 08:35:57 +00:00
|
|
|
double price_value = atof(price);
|
2024-09-29 08:17:52 +00:00
|
|
|
if (strstr(decoded_item, decoded_search) != NULL) {
|
2024-09-29 08:35:57 +00:00
|
|
|
printf("%s\n%.2f\n", menu_item, price_value);
|
2024-09-29 08:17:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Nacitanych %d poloziek.\n", count);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|