This commit is contained in:
Weber 2024-03-22 00:26:40 +00:00
parent 82c883e82a
commit 54e3f319a8

View File

@ -27,19 +27,11 @@ int main() {
char line[1024];
while (fgets(line, sizeof(line), stdin) != NULL) {
int vote_count;
char name[1024];
sscanf(line, "%d %[^\n]", &vote_count, name);
char *prev_name = NULL;
int total_vote_count = 0;
if (student_count > 0 && strcmp(students[student_count - 1].name, name) == 0) {
vote_count += students[student_count - 1].vote_count;
}
if (student_count >= students_capacity) {
students_capacity = (students_capacity + 1) * 2;
student_t *new_students = realloc(students, students_capacity * sizeof(student_t));
@ -64,7 +56,7 @@ int main() {
}
for (int i = 0; i < student_count; i++) {
free(student_t.name);
free(students[i].name);
}
free(students);