Оновити 'cv5/program.c'
This commit is contained in:
parent
e60a359b7a
commit
67575827e3
@ -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++) {
|
||||||
@ -79,4 +80,4 @@ int main(){
|
|||||||
printf("%d %s\n", databaza[i].votes, databaza[i].name);
|
printf("%d %s\n", databaza[i].votes, databaza[i].name);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user