This commit is contained in:
Tančáková 2024-03-20 16:59:06 +01:00
parent 7900f4a220
commit c8e58d8048

View File

@ -50,10 +50,22 @@ int main() {
return 1;
}
// Pridanie študenta do databázy
strcpy(database[size].name, name);
database[size].votes = votes;
size++;
// Hľadanie študenta v databáze
int found = 0;
for (int j = 0; j < size; j++) {
if (strcmp(database[j].name, name) == 0) {
database[j].votes += votes;
found = 1;
break;
}
}
// Pridanie nového študenta do databázy
if (!found) {
strcpy(database[size].name, name);
database[size].votes = votes;
size++;
}
}
// Zoradenie databázy podľa počtu hlasov a abecedne