usaa24/cv1/program.c

66 lines
1.7 KiB
C
Raw Normal View History

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: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) {
break;
price[strcspn(price, "\n")] = 0;
decode_hacker_script(menu_item, decoded_item);
if (strstr(decoded_item, decoded_search) != NULL) {
printf("%s\n%s\n", menu_item, price);
count++;
}
}
printf("Nacitanych %d poloziek.\n", count);
return 0;
}
2024-09-29 08:20:32 +00:00
}