diff options
added sem 12
1 files changed, 57 insertions, 0 deletions
| -rw-r--r-- | Sem. 12/tesk2.cpp | 57 |
diff --git a/Sem. 12/tesk2.cpp b/Sem. 12/tesk2.cpp new file mode 100644 index 0000000..fc7df86 --- /dev/null +++ b/Sem. 12/tesk2.cpp @@ -0,0 +1,57 @@ +#include <iostream> +using namespace std; + + +bool isSymbol(char ch) +{ + return ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z'); +} +bool isVowel(char ch) +{ + switch (ch) + { + case 'A': + case 'O': + case 'I': + case 'U': + case 'E': + case 'a': + case 'o': + case 'i': + case 'u': + case 'e':return true; + } + return false; +} +void countVowelAndCons(const char* str, int& vowelCount, int& consCount) +{ + while (*str != '\0') + { + if (isSymbol(*str)) + { + if (isVowel(*str)) + vowelCount++; + else + consCount++; + } + str++; + } +} + +bool isBalanced(const char* str) +{ + int vowelCount = 0, consCount = 0; + + countVowelAndCons(str, vowelCount, consCount); + + return vowelCount == consCount; +} + +int main() +{ + const char* str = "TestMeau"; + + cout << isBalanced(str) << endl; + + +}
\ No newline at end of file |
