Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 12 / tesk2.cpp
blob: e41c06979f53667e73e8516f53630cd2618514b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#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;


}