2024-10-01 13:36:19 +00:00
|
|
|
#include <stdio.h>
|
2024-10-01 21:47:00 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
2024-10-03 10:42:43 +00:00
|
|
|
|
2024-10-03 10:59:36 +00:00
|
|
|
#define MAX_DISHES 100
|
|
|
|
#define MAX_LENGTH 100
|
|
|
|
|
|
|
|
|
|
|
|
void decode(char *text) {
|
|
|
|
for (int i = 0; text[i] != '\0'; i++) {
|
|
|
|
|
|
|
|
switch (text[i]) {
|
|
|
|
case '0': text[i] = 'o'; break;
|
|
|
|
case '1': text[i] = 'i'; break;
|
|
|
|
case '2': text[i] = 'z'; break;
|
|
|
|
case '3': text[i] = 'e'; break;
|
|
|
|
case '4': text[i] = 'a'; break;
|
|
|
|
case '5': text[i] = 's'; break;
|
|
|
|
case '6': text[i] = 'b'; break;
|
|
|
|
case '7': text[i] = 't'; break;
|
|
|
|
case '8': text[i] = 'b'; break;
|
|
|
|
case '9': text[i] = 'q'; break;
|
2024-10-01 21:47:00 +00:00
|
|
|
}
|
2024-10-03 10:59:36 +00:00
|
|
|
text[i] = tolower(text[i]);
|
2024-10-01 21:47:00 +00:00
|
|
|
}
|
|
|
|
}
|
2024-10-02 17:25:52 +00:00
|
|
|
|
2024-10-01 13:36:19 +00:00
|
|
|
int main() {
|
2024-10-03 10:59:36 +00:00
|
|
|
char slovo[MAX_LENGTH];
|
|
|
|
char dish_name[MAX_LENGTH];
|
|
|
|
char price[MAX_LENGTH];
|
|
|
|
int count = 0;
|
2024-10-01 22:29:12 +00:00
|
|
|
|
2024-10-02 17:25:52 +00:00
|
|
|
|
2024-10-03 10:59:36 +00:00
|
|
|
printf("Zadaj hladanu surovinu:\n");
|
|
|
|
fgets(slovo, MAX_LENGTH, stdin);
|
|
|
|
slovo[strcspn(slovo, "\n")] = 0;
|
|
|
|
decode(slovo);
|
2024-10-01 21:47:00 +00:00
|
|
|
|
2024-10-03 10:42:43 +00:00
|
|
|
printf("Zadaj jedalny listok:\n");
|
|
|
|
while (1) {
|
2024-10-03 10:59:36 +00:00
|
|
|
if (fgets(dish_name, MAX_LENGTH, stdin) == NULL || strcmp(dish_name, "\n") == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
dish_name[strcspn(dish_name, "\n")] = 0;
|
|
|
|
// Načítanie ceny jedla
|
|
|
|
if (fgets(price, MAX_LENGTH, stdin) == NULL || strcmp(price, "\n") == 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
price[strcspn(price, "\n")] = 0;
|
2024-10-01 22:00:31 +00:00
|
|
|
|
2024-10-03 10:59:36 +00:00
|
|
|
char normal_dish[MAX_LENGTH];
|
|
|
|
strcpy(normal_dish, dish_name);
|
|
|
|
decode(normal_dish);
|
|
|
|
if (strstr(normal_dish, slovo) != NULL) {
|
|
|
|
printf("%s\n%s\n", dish_name, price);
|
2024-10-01 21:47:00 +00:00
|
|
|
}
|
2024-10-03 10:59:36 +00:00
|
|
|
count++;
|
2024-10-01 21:47:00 +00:00
|
|
|
}
|
2024-10-02 17:25:52 +00:00
|
|
|
|
2024-10-03 10:44:04 +00:00
|
|
|
printf("Nacitanych %d poloziek.\n", count);
|
2024-10-01 13:36:19 +00:00
|
|
|
return 0;
|
2024-10-01 22:00:31 +00:00
|
|
|
}
|
2024-10-03 10:59:36 +00:00
|
|
|
|
|
|
|
|