Обновить du4/program.c

This commit is contained in:
Bohdana Marchenko 2025-03-20 22:18:20 +00:00
parent 6296e3b2f4
commit b84610cbbc

View File

@ -38,8 +38,8 @@ int main() {
while (fgets(line, SIZE, stdin) != NULL) {
char *end = NULL;
int votes = strtol(line, &end, 10);
if (votes == 0) {
continue; // Neplatný vstup, preskočiť
if (end == line || *end == '\0' || votes <= 0) {
break; // Neplatný vstup, ukončiť načítanie
}
// Preskočiť medzeru po čísle hlasov