diff --git a/du2/program.c b/du2/program.c index 4cec9d2..f8df7bf 100644 --- a/du2/program.c +++ b/du2/program.c @@ -3,8 +3,8 @@ #include #define SIZE 100 - -struct student { + +struct student { char meno[SIZE]; int hlasy; @@ -25,10 +25,9 @@ int porovnaj(const void* p1, const void* p2) { struct student* s1 = (struct student*)p1; struct student* s2 = (struct student*)p2; - if (s2->hlasy > s1->hlasy) return -1; - if (s2->hlasy < s1->hlasy) return 1; - return strcmp(s1->meno, s2->meno); + if (s2->hlasy != s1->hlasy) return s2->hlasy - s1->hlasy; + return strcmp(s1->meno, s2->meno); } int main() { @@ -71,7 +70,6 @@ int main() { if (zaciatok_mena[velkost_mena - 1] == '\n') { velkost_mena--; } - if (velkost_mena <= 0) { continue; } @@ -106,4 +104,3 @@ int main() { return 0; } -