commit
This commit is contained in:
parent
e011aa19aa
commit
1cf7630708
@ -23,14 +23,12 @@ static int cmp(const void *a, const void *b) {
|
||||
|
||||
int main(void) {
|
||||
char line[MAX_LINE];
|
||||
|
||||
while (fgets(line, sizeof(line), stdin)) {
|
||||
line[strcspn(line, "\n")] = '\0';
|
||||
char *end;
|
||||
long votes = strtol(line, &end, 10);
|
||||
if (end == line || votes <= 0 || *end != ' ')
|
||||
break;
|
||||
|
||||
char *name = end + 1;
|
||||
if (*name == '\0')
|
||||
break;
|
||||
@ -51,7 +49,7 @@ int main(void) {
|
||||
return 1;
|
||||
}
|
||||
qsort(students, count, sizeof(Student), cmp);
|
||||
|
||||
printf("Vysledky:\n");
|
||||
for (int i = 0; i < count; i++)
|
||||
printf("%ld %s\n", students[i].votes, students[i].name);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user