|
|
@ -1,5 +1,7 @@ |
|
|
|
#include "operationHandler.h" |
|
|
|
#include <stdbool.h> |
|
|
|
#include <ctype.h> |
|
|
|
#include <stdlib.h> |
|
|
|
|
|
|
|
bool checkOperationInput(int input) { |
|
|
|
switch (input) { |
|
|
@ -8,3 +10,27 @@ bool checkOperationInput(int input) { |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
bool containsTwoNumbers(const char* str) { |
|
|
|
int numbersCount = 0; |
|
|
|
bool hasSpace = false; |
|
|
|
bool isInNumber = false; |
|
|
|
|
|
|
|
for (int i = 0; str[i] != '\0'; i++) { |
|
|
|
if (isdigit(str[i])) { |
|
|
|
if (!isInNumber) { |
|
|
|
isInNumber = true; |
|
|
|
numbersCount++; |
|
|
|
} |
|
|
|
} else if (str[i] == ' ' && isInNumber) { |
|
|
|
hasSpace = true; |
|
|
|
isInNumber = false; |
|
|
|
} else if (str[i] == ' ' && !isInNumber) { |
|
|
|
hasSpace = false; |
|
|
|
} else { |
|
|
|
hasSpace = false; |
|
|
|
isInNumber = false; |
|
|
|
} |
|
|
|
} |
|
|
|
return (numbersCount == 2 && hasSpace); |
|
|
|
} |