From bf947abf892fb547288451ea0863fe73f9bbcd8b Mon Sep 17 00:00:00 2001 From: Vladyslav Korzun Date: Fri, 17 Mar 2023 14:35:54 +0000 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB(?= =?UTF-8?q?=D0=B0)=20=D0=BD=D0=B0=20'du5/program.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du5/program.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/du5/program.c b/du5/program.c index c287340..cfe22f5 100644 --- a/du5/program.c +++ b/du5/program.c @@ -43,6 +43,7 @@ int compare_students(const void* a, const void* b) { int main(){ int STOP = 0; + int counter = 0; struct student databaza[SIZE]; memset(databaza, 0, SIZE*sizeof(struct student)); int size = 0; @@ -86,14 +87,19 @@ int main(){ else { databaza[id].votes += value; } + counter++; } qsort(databaza, size, sizeof(struct student), compare_students); - + if(counter != 0){ printf("Vysledky:\n"); for (int i = 0; i < size; i++) { printf("%d", databaza[i].votes); printf(" %s\n", databaza[i].name); } + } + else{ + printf("Nepodarilo nacitat nic\n"); + } return 0; }