funguje
This commit is contained in:
parent
7900f4a220
commit
c8e58d8048
@ -50,11 +50,23 @@ int main() {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pridanie študenta do databázy
|
// 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);
|
strcpy(database[size].name, name);
|
||||||
database[size].votes = votes;
|
database[size].votes = votes;
|
||||||
size++;
|
size++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Zoradenie databázy podľa počtu hlasov a abecedne
|
// Zoradenie databázy podľa počtu hlasov a abecedne
|
||||||
qsort(database, size, sizeof(struct student), compare);
|
qsort(database, size, sizeof(struct student), compare);
|
||||||
|
Loading…
Reference in New Issue
Block a user