#include #include using namespace std; bool is_balanced(string str) { char vowels[5] = {'a', 'e', 'i', 'o', 'u'}; int vowel_count_1 = 0; int vowel_count_2 = 0; int str_len = str.size(); int half_count = str.size() / 2; int next_half = 0; bool odd = str.size() % 2 ? 1 : 0; string first_half = str.substr(0, half_count); if (odd) { next_half = half_count; next_half += 1; } else { next_half = half_count; } string secound_half = str.substr(next_half, half_count); cout << first_half << endl; for (char c : first_half) { for (char v : vowels) { if (tolower(c) == v) { vowel_count_1++; } } } cout << vowel_count_1 << endl; cout << secound_half << endl; for (char c : secound_half) { for (char v : vowels) { if (tolower(c) == v) { vowel_count_2++; } } } cout << vowel_count_2 << endl; return vowel_count_1 == vowel_count_2; } int main() { string case_values[7] = { "racecar", "Lorem Ipsum", "Kitty Ipsum", "string", " ", "abcdefghijklmnopqrstuvwxyz", "123A#b!E&*456-o.U" }; int length = sizeof(case_values) / sizeof(case_values[0]); for (int i = 0; i < length; i++) { cout << "-- " << case_values[i] << " --" << endl; bool value = is_balanced(case_values[i]); if (value) { cout << "True" << endl; } else { cout << "False" << endl; } cout << "-----------------------------------" << endl; } return 0; }