This commit is contained in:
Sadchenko 2024-03-28 23:30:40 +01:00
parent 7cbecc2e83
commit 55ce047b2d

View File

@ -23,6 +23,10 @@ bool check_spaces(const char* str) {
if (str[len - 2] == '+' || str[len - 2] == '-' || str[len - 2] == '*' || str[len - 2] == '/') if (str[len - 2] == '+' || str[len - 2] == '-' || str[len - 2] == '*' || str[len - 2] == '/')
return false; return false;
if (isdigit(str[len - 2]) && str[len - 1] == ' ')
return false;
return true; return true;
} }
@ -46,6 +50,11 @@ char* check_math_problem(const char* problem) {
return "CHYBA"; return "CHYBA";
} }
// Проверяем, что после результата нет пробела
if (strchr(problem, '=') - strchr(problem, ' ') == 2) {
return "CHYBA";
}
double result; double result;
switch (sing) { switch (sing) {
case '+': case '+':
@ -88,3 +97,4 @@ int main() {
return 0; return 0;
} }