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

This commit is contained in:
Yevhen Kozirovskyi 2024-10-17 16:49:26 +00:00
parent 276b7f7ea1
commit 8c3c003af9

View File

@ -47,6 +47,10 @@ int main() {
char* konec; char* konec;
double chislo = strtod(bufer, &konec); double chislo = strtod(bufer, &konec);
if (*konec == '\n' && *bufer != '\n' && *bufer != ' ') { if (*konec == '\n' && *bufer != '\n' && *bufer != ' ') {
if (konec - bufer == 1) {
printf("bad input\n");
exit(1);
}
push(&stek, chislo); push(&stek, chislo);
} else if (strcmp(konec, "+\n") == 0) { } else if (strcmp(konec, "+\n") == 0) {
if (isEmpty(&stek)) { if (isEmpty(&stek)) {
@ -103,7 +107,7 @@ int main() {
} }
push(&stek, a / b); push(&stek, a / b);
} else { } else {
printf("no input\n"); printf("bad input\n");
exit(1); exit(1);
} }
for (int i = 0; i < stek.vershina; i++) { for (int i = 0; i < stek.vershina; i++) {