From 0e325848937ac0067aacd4de7e5c3564f37e80d7 Mon Sep 17 00:00:00 2001 From: mr314ot Date: Thu, 9 Oct 2025 19:18:23 +0200 Subject: [PATCH] du2 - 10 --- du2/program.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/du2/program.c b/du2/program.c index fa9aafb..50430fc 100644 --- a/du2/program.c +++ b/du2/program.c @@ -30,11 +30,12 @@ int read_pizza(struct pizza *item) { return 0; } line2[strcspn(line2, "\n")] = '\0'; - + + float value; if (sscanf(line2, "%f", &value) != 1) { return 0; } - + strncpy(item->name, line1, LINESIZE - 1); item->name[LINESIZE - 1] = '\0'; return 1; @@ -75,13 +76,12 @@ int main() { list[count++] = tmp; } - //triedenie - sort_pizzas(list, count); - - //vypis listka - for (int i = 0; i < count; i++){ - printf("%s\n", list[i].name); - printf("%.6f\n", list[i].price); + if (count > 0) { + sort_pizzas(list, count); + for (int i = 0; i < count; i++){ + printf("%s\n", list[i].name); + printf("%.6f\n", list[i].price); + } } return 0;