Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 12 / tesk2.cpp
diff options
context:
space:
mode:
Commit5c727824c4597c38fb4248ad20d3c9789201f0d3 (patch)
Author
 Angeld55 <angel_dimitriev@abv.bg>
2020-12-27 16:25:51 +0200
Committer
 Angeld55 <angel_dimitriev@abv.bg>
2020-12-27 16:25:51 +0200
Files5c995c476b5bcf3e4ce8401464472c551fea265e /Sem. 12/tesk2.cpp
Introduction_to_programming_FMI-5c727824c4597c38fb4248ad20d3c9789201f0d3.tar
Introduction_to_programming_FMI-5c727824c4597c38fb4248ad20d3c9789201f0d3.tar.gz
Introduction_to_programming_FMI-5c727824c4597c38fb4248ad20d3c9789201f0d3.zip
Parent5bd416a7bcc4bd6f6bac606b825c3f22e0b4530e (diff)
added sem 12
1 files changed, 57 insertions, 0 deletions
-rw-r--r--Sem. 12/tesk2.cpp57
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