diff --git a/anketa b/anketa index 7742f1a..2f218f7 100755 Binary files a/anketa and b/anketa differ diff --git a/anketa.c b/anketa.c index 3acc53c..2ea5d4e 100644 --- a/anketa.c +++ b/anketa.c @@ -45,11 +45,16 @@ int add_student(struct student* students, const char* name, int votes){ int compare(const void* s1,const void* s2){ struct student* stud1=(struct student*)s1; struct student* stud2=(struct student*)s2; - return stud1->votes==stud2->votes?0:stud1->votesvotes?1:-1; + if(stud1->votes==stud2->votes){ + return 0; + }else if(stud1->votesvotes){ + return 1; + } + return -1; } void sort_students(struct student* students){ - qsort(students, count_students(students), sizeof(struct student), compare); + qsort(students,count_students(students),sizeof(struct student),compare); } void print_students(struct student* students){ diff --git a/anketa.o b/anketa.o index 3407871..2ee2956 100644 Binary files a/anketa.o and b/anketa.o differ diff --git a/main.c b/main.c index 47e8013..f8245ee 100644 --- a/main.c +++ b/main.c @@ -29,7 +29,8 @@ int main(int argc,char** argv){ break; case 'p': print_students(students); break; - case 'o': sort_students(students); + case 'o': sort_students(students); + print_students(students); break; case 'c': count_votes(students); break; diff --git a/main.o b/main.o index d754cad..f165c4b 100644 Binary files a/main.o and b/main.o differ diff --git a/vstup.txt b/vstup.txt index 0a41421..481e77c 100644 --- a/vstup.txt +++ b/vstup.txt @@ -2,4 +2,9 @@ Anka 10 Marcel 30 - +Anka +5 +Jozko +590 +Anka +1000