2024-03-13 09:55:11 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2024-03-20 12:59:55 +00:00
|
|
|
#define MAX_NAME_LENGTH 100
|
2024-03-20 14:08:46 +00:00
|
|
|
#define MAX_BUFFER_LENGTH 256
|
2024-03-20 12:59:55 +00:00
|
|
|
|
2024-03-20 14:57:31 +00:00
|
|
|
#define SIZE 100
|
2024-03-20 14:08:46 +00:00
|
|
|
|
2024-03-20 14:57:31 +00:00
|
|
|
struct student {
|
|
|
|
char name[SIZE];
|
|
|
|
int votes;
|
|
|
|
};
|
|
|
|
struct student database[SIZE];
|
|
|
|
memset(database, 0, SIZE * sizeof(struct student));
|
|
|
|
int size = 0;
|
|
|
|
char line[SIZE];
|
|
|
|
memset(line, 0, SIZE);
|
|
|
|
char *r = fgets(line, SIZE, stdin);
|
|
|
|
if (r == NULL) {
|
|
|
|
// Nastal koniec vstupu
|
|
|
|
}
|
|
|
|
char *end = NULL;
|
|
|
|
int value = strtol(line, &end, 10);
|
|
|
|
if (value == 0) {
|
|
|
|
// Prevod sa nepodaril
|
2024-03-13 09:55:11 +00:00
|
|
|
}
|
|
|
|
|
2024-03-20 14:57:31 +00:00
|
|
|
// Pre pokračovanie získame meno študenta
|
|
|
|
char name[SIZE];
|
|
|
|
memset(name, 0, SIZE);
|
|
|
|
char *name_start = end + 1;
|
|
|
|
int name_length = strlen(name_start) - 1; // Nezahrňujeme koniec riadka
|
|
|
|
if (name_length > 0) {
|
|
|
|
memcpy(name, name_start, name_length);
|
|
|
|
} else {
|
|
|
|
// Nepodarilo sa načítať meno
|
|
|
|
}
|
|
|
|
int find_student(struct student *students, int size, const char *name) {
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
if (strcmp(students[i].name, name) == 0) {
|
|
|
|
return i; // Nájdený študent
|
2024-03-20 13:52:38 +00:00
|
|
|
}
|
2024-03-13 09:55:11 +00:00
|
|
|
}
|
2024-03-20 14:57:31 +00:00
|
|
|
return -1; // Študent nenájdený
|
|
|
|
}
|
|
|
|
int id = find_student(database, size, name);
|
|
|
|
if (id < 0) {
|
|
|
|
//
|
|
|
|
|
2024-03-20 13:52:38 +00:00
|
|
|
|
2024-03-13 09:55:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|