#include <iostream>
int countEvenRecursive(int arr[], int size, int index) {
if (index == size) {
return 0;
}
if (arr[index] % 2 == 0) {
return 1 + countEvenRecursive(arr, size, index + 1);
} else {
return countEvenRecursive(arr, size, index + 1);
}
}
int main() {
int a[] = {1, 4, 6, 3, 7, 11, 8, 9, 10};
int size = sizeof(a) / sizeof(a[0]);
int evenCount = countEvenRecursive(a, size, 0);
std::cout << "The number of even values in the array is: " << evenCount << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKaW50IGNvdW50RXZlblJlY3Vyc2l2ZShpbnQgYXJyW10sIGludCBzaXplLCBpbnQgaW5kZXgpIHsKICBpZiAoaW5kZXggPT0gc2l6ZSkgewogICAgcmV0dXJuIDA7IAogIH0KCiAgaWYgKGFycltpbmRleF0gJSAyID09IDApIHsKICAgIHJldHVybiAxICsgY291bnRFdmVuUmVjdXJzaXZlKGFyciwgc2l6ZSwgaW5kZXggKyAxKTsKICB9IGVsc2UgewogICAgcmV0dXJuIGNvdW50RXZlblJlY3Vyc2l2ZShhcnIsIHNpemUsIGluZGV4ICsgMSk7CiAgfQp9CgppbnQgbWFpbigpIHsKICBpbnQgYVtdID0gezEsIDQsIDYsIDMsIDcsIDExLCA4LCA5LCAxMH07CiAgaW50IHNpemUgPSBzaXplb2YoYSkgLyBzaXplb2YoYVswXSk7CgogIGludCBldmVuQ291bnQgPSBjb3VudEV2ZW5SZWN1cnNpdmUoYSwgc2l6ZSwgMCk7CgogIHN0ZDo6Y291dCA8PCAiVGhlIG51bWJlciBvZiBldmVuIHZhbHVlcyBpbiB0aGUgYXJyYXkgaXM6ICIgPDwgZXZlbkNvdW50IDw8IHN0ZDo6ZW5kbDsKCiAgcmV0dXJuIDA7Cn0=