This commit is contained in:
Oleksandr Vyshniakov 2025-09-27 20:46:28 +02:00
parent 6dcb50751c
commit 01380c0ffc
2 changed files with 21 additions and 20 deletions

Binary file not shown.

View File

@ -84,7 +84,7 @@ int read_pizza (struct pizza* item) {
}
Line_druha [strcspn(Line_druha, "\n")] = '\0';
float value;
if (sscanf(Line_jeden, "%f", &value ) !=1) {
if (sscanf(Line_druha, "%f", &value ) !=1) {
return 0;
}
item->prize = value;
@ -95,28 +95,29 @@ int read_pizza (struct pizza* item) {
int main() {
char poisk[LINESIZE];
char s_item[LINESIZE];
struct pizza menu[MAX_PIZZAS];
int pocet = 0;
printf("Zadaj hladanu surovinu:\n");
fgets(poisk, sizeof(poisk), stdin);
fgets(s_item, sizeof(s_item), stdin);
s_item[strcspn(s_item, "\n")] = '\0';
poisk[strcspn(poisk, "\n")] = '\0';
struct pizza jedalny_listok [MAX_PIZZAS];
printf("Zadaj hlavny listok:\n");
while (pocet < MAX_PIZZAS && read_pizza(&menu[pocet])) {
pocet++;
}
for (int i = 0; i < pocet; i++) {
if (search_string(menu[i].name, s_item) !=-1) {
printf("%s\n", menu[i].name);
printf("%.2f\n", menu[i].prize);
}
}
printf("Nacitannych %s poloziek.\n", pocet);
int vsetky = 0;
while (vsetky<MAX_PIZZAS && read_pizza(&jedalny_listok[vsetky])) {
vsetky++;
}
int count = 0;
for (int i = 0; i < vsetky; i++) {
if (search_string(jedalny_listok[i].name, poisk)!= -1) {
printf("%s\n", jedalny_listok[i].name);
printf("%s\n", jedalny_listok[i].prize);
count++;
}
}
return 0;
}