funguje
This commit is contained in:
parent
0f0aceb5c9
commit
f8f468a3a8
@ -26,28 +26,29 @@ int main() {
|
||||
|
||||
srand(time(NULL)); // Inicializácia generátora náhodných čísel
|
||||
|
||||
// Čítanie vstupu a vytváranie databázy
|
||||
char input[SIZE];
|
||||
while (fgets(input, SIZE, stdin) != NULL) {
|
||||
int votes;
|
||||
char name[SIZE];
|
||||
sscanf(input, "%d %s %s", &votes, name, name + strlen(name) + 1); // Načítanie počtu hlasov, mena a priezviska
|
||||
// Definícia vstupu
|
||||
char input[] = "10 Terian Dis\n";
|
||||
|
||||
int id = find_student(database, size, name);
|
||||
if (id < 0) {
|
||||
strcpy(database[size].name, name);
|
||||
database[size].votes = votes;
|
||||
size++;
|
||||
} else {
|
||||
database[id].votes += votes;
|
||||
}
|
||||
// Zobrazenie definície vstupu
|
||||
printf("Vstup:\n%s\n", input);
|
||||
|
||||
// Čítanie vstupu a vytváranie databázy
|
||||
int votes;
|
||||
char name[SIZE];
|
||||
sscanf(input, "%d %s %s", &votes, name, name + strlen(name) + 1); // Načítanie počtu hlasov, mena a priezviska
|
||||
|
||||
int id = find_student(database, size, name);
|
||||
if (id < 0) {
|
||||
strcpy(database[size].name, name);
|
||||
database[size].votes = votes;
|
||||
size++;
|
||||
} else {
|
||||
database[id].votes += votes;
|
||||
}
|
||||
|
||||
// Výpis databázy
|
||||
printf("Databaza:\n");
|
||||
for (int i = 0; i < size; i++) {
|
||||
printf("%d %s\n", database[i].votes, database[i].name);
|
||||
}
|
||||
printf("\nVysledky:\n");
|
||||
printf("%d %s\n", database[0].votes, database[0].name);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user