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