From 7806888c40dab2aec8dabe128b64f678f4c8fef6 Mon Sep 17 00:00:00 2001 From: Yevhen Kozirovskyi Date: Thu, 17 Oct 2024 16:57:43 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20cv3/program.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cv3/program.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index b64bce6..6c3313e 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -47,10 +47,7 @@ int main() { while (fgets(bufer, sizeof(bufer), stdin) != NULL) { char* konec; double chislo = strtod(bufer, &konec); - if (chislo == 0 && strcmp(bufer, "0\n") != 0) { - printf("bad input\n"); - exit(1); - } + if (*konec == '\n' && *bufer != '\n' && *bufer != ' ') { push(&stek, chislo); } else if (strcmp(konec, "+\n") == 0) { @@ -111,6 +108,7 @@ int main() { } else if (isalpha(konec[-1])) { printf("bad input\n"); exit(1); + return 0; } else { printf("bad input\n"); exit(1); @@ -122,4 +120,4 @@ int main() { } printf("no input\n"); return 0; -} +} \ No newline at end of file