Solved the problem according to the following algorithm. We have a maximum and current variable. We iterate over the array if the element is found = 0; then we increase the value of the counter by one. Otherwise, if the current sequence is larger than the maximum, then we assign the maximum current one. And reset the counter. The program just shows me the number of elements from 0. What I did wrong.
#include <iostream> using namespace std; int main() { const int size = 11; int arr[size] = {100, 1, 0, 36, 0000, 74, 00, 666, 32, 000000, 17}; int temp = 0; int max = 0; for (int i = 0; i < size; ++i) { if(arr[i] == 0) { ++temp; } else { if(temp > max) { max = temp; } } } cout << "Max is :" << max << endl; return 0; }