This commit is contained in:
Jana Kapalková 2026-03-12 18:56:16 +01:00
parent e011aa19aa
commit 1cf7630708

View File

@ -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,9 +49,9 @@ 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);
return 0;
}
}