78 lines
1.4 KiB
C
78 lines
1.4 KiB
C
#include <string.h>
|
|
#include <stdio.h>
|
|
|
|
|
|
void replace(char* DishName);
|
|
|
|
struct MenuItem {
|
|
char category[50];
|
|
char dish[50];
|
|
float price;
|
|
};
|
|
|
|
char answer1[100];
|
|
|
|
int main(void) {
|
|
|
|
|
|
struct MenuItem menu[] = {
|
|
{"Pizza", "Margarita", 4.4},
|
|
{"Pizza", "Cucumber", 4.4},
|
|
{"Pizza", "Ajika", 4.4},
|
|
{"Pizza", "Paperoni", 4.4}
|
|
};
|
|
|
|
|
|
printf("Zadaj hladanu surovinu: ");
|
|
fgets(answer1, 100, stdin);
|
|
|
|
|
|
if (answer1[strlen(answer1) - 1] == '\n') {
|
|
answer1[strlen(answer1) - 1] = '\0';
|
|
}
|
|
|
|
int MenuSize = sizeof(menu) / sizeof(menu[0]);
|
|
int found = 0;
|
|
|
|
|
|
for (size_t i = 0; i < MenuSize; i++) {
|
|
|
|
if (strstr(menu[i].dish, answer1) != NULL) {
|
|
found = 1;
|
|
|
|
replace(menu[i].dish);
|
|
printf("Chcete to to: %s, Cena: %.2f\n", menu[i].dish, menu[i].price);
|
|
}
|
|
}
|
|
|
|
|
|
if (!found) {
|
|
printf("Zadana surovina nebola najdena.\n");
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|
|
void replace(char* DishName) {
|
|
|
|
char original[] = "aAeEiIoOsSzZ";
|
|
|
|
char replacement[] = "443311005522";
|
|
|
|
int l = strlen(DishName);
|
|
|
|
|
|
for (int i = 0; i < l; i++) {
|
|
|
|
for (int j = 0; j < strlen(original); j++) {
|
|
if (DishName[i] == original[j]) {
|
|
|
|
DishName[i] = replacement[j];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|