From 55ce047b2daa5d21f5be8cd61717c3ce266c85e4 Mon Sep 17 00:00:00 2001 From: Mykyta Sadchenko Date: Thu, 28 Mar 2024 23:30:40 +0100 Subject: [PATCH] r --- a1/program.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/a1/program.c b/a1/program.c index 0323371..0f40190 100644 --- a/a1/program.c +++ b/a1/program.c @@ -23,6 +23,10 @@ bool check_spaces(const char* str) { if (str[len - 2] == '+' || str[len - 2] == '-' || str[len - 2] == '*' || str[len - 2] == '/') return false; + + if (isdigit(str[len - 2]) && str[len - 1] == ' ') + return false; + return true; } @@ -46,6 +50,11 @@ char* check_math_problem(const char* problem) { return "CHYBA"; } + // Проверяем, что после результата нет пробела + if (strchr(problem, '=') - strchr(problem, ' ') == 2) { + return "CHYBA"; + } + double result; switch (sing) { case '+': @@ -88,3 +97,4 @@ int main() { return 0; } +