Оновити 'cv5/program.c'

This commit is contained in:
Kapliuk 2024-03-21 19:04:39 +00:00
parent e60a359b7a
commit 67575827e3

View File

@ -3,7 +3,6 @@
#include <string.h>
#include <math.h>
#define SIZE 100
struct student {
char name[SIZE];
int votes;
@ -42,6 +41,7 @@ int main(){
memset(databaza,0,SIZE*sizeof(struct student));
int size = 0;
while(fgets(line,SIZE,stdin) && line[0] != '\n'){
memset(name,0,SIZE);
if(line == NULL){
break;
}
@ -72,6 +72,7 @@ int main(){
counter++;
}
counter--;
qsort(databaza, size, sizeof(struct student), compare_names);
qsort(databaza, size, sizeof(struct student), compare_votes);
printf("Vysledky:\n");
for(int i = 0; i < size; i++) {
@ -79,4 +80,4 @@ int main(){
printf("%d %s\n", databaza[i].votes, databaza[i].name);
}
return 0;
}
}