|
@ -1,5 +1,7 @@ |
|
|
#include "operationHandler.h" |
|
|
#include "operationHandler.h" |
|
|
#include <stdbool.h> |
|
|
#include <stdbool.h> |
|
|
|
|
|
#include <ctype.h> |
|
|
|
|
|
#include <stdlib.h> |
|
|
|
|
|
|
|
|
bool checkOperationInput(int input) { |
|
|
bool checkOperationInput(int input) { |
|
|
switch (input) { |
|
|
switch (input) { |
|
@ -7,4 +9,28 @@ bool checkOperationInput(int input) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
return false; |
|
|
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); |
|
|
} |
|
|
} |