# Find the longest sequence 0 in the array [C ++]

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; }` `
• if you look at this line if (arr [i] == 0) then for a program that 000000, that 00 is still zero, so this check does not count you how many zeros are written, but whether it is just zero by mathematical to the standards. - Comfmore

` ` else { if(temp > max) { max = temp; } temp = 0; // здесь обнулить забыли }` `