From 5c727824c4597c38fb4248ad20d3c9789201f0d3 Mon Sep 17 00:00:00 2001 From: Angeld55 Date: Sun, 27 Dec 2020 16:25:51 +0200 Subject: added sem 12 --- Sem. 12/tesk2.cpp | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Sem. 12/tesk2.cpp (limited to 'Sem. 12/tesk2.cpp') 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 +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 -- cgit v1.3.1-23-gd82d