Оновити '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 <string.h>
#include <math.h> #include <math.h>
#define SIZE 100 #define SIZE 100
struct student { struct student {
char name[SIZE]; char name[SIZE];
int votes; int votes;
@ -42,6 +41,7 @@ int main(){
memset(databaza,0,SIZE*sizeof(struct student)); memset(databaza,0,SIZE*sizeof(struct student));
int size = 0; int size = 0;
while(fgets(line,SIZE,stdin) && line[0] != '\n'){ while(fgets(line,SIZE,stdin) && line[0] != '\n'){
memset(name,0,SIZE);
if(line == NULL){ if(line == NULL){
break; break;
} }
@ -72,6 +72,7 @@ int main(){
counter++; counter++;
} }
counter--; counter--;
qsort(databaza, size, sizeof(struct student), compare_names);
qsort(databaza, size, sizeof(struct student), compare_votes); qsort(databaza, size, sizeof(struct student), compare_votes);
printf("Vysledky:\n"); printf("Vysledky:\n");
for(int i = 0; i < size; i++) { for(int i = 0; i < size; i++) {