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) {
|
int main(void) {
|
||||||
char line[MAX_LINE];
|
char line[MAX_LINE];
|
||||||
|
|
||||||
while (fgets(line, sizeof(line), stdin)) {
|
while (fgets(line, sizeof(line), stdin)) {
|
||||||
line[strcspn(line, "\n")] = '\0';
|
line[strcspn(line, "\n")] = '\0';
|
||||||
char *end;
|
char *end;
|
||||||
long votes = strtol(line, &end, 10);
|
long votes = strtol(line, &end, 10);
|
||||||
if (end == line || votes <= 0 || *end != ' ')
|
if (end == line || votes <= 0 || *end != ' ')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
char *name = end + 1;
|
char *name = end + 1;
|
||||||
if (*name == '\0')
|
if (*name == '\0')
|
||||||
break;
|
break;
|
||||||
@ -51,9 +49,9 @@ int main(void) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
qsort(students, count, sizeof(Student), cmp);
|
qsort(students, count, sizeof(Student), cmp);
|
||||||
|
printf("Vysledky:\n");
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
printf("%ld %s\n", students[i].votes, students[i].name);
|
printf("%ld %s\n", students[i].votes, students[i].name);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user