The negative elements plug into groups, calculate the number of groups with 0

using namespace std; void main() { setlocale(LC_ALL, "ukr"); srand(time(NULL)); const int n = 15; int arr[n], m = 0,p = 0; for (int i = 0; i < n; i++) { arr[i] = rand() % 10  5; cout << arr[i] << " "; } cout << endl; for (int i = 0; i < n; i++) { if ((arr[i] >= 0) && (arr[i] == 0)) m++; // else // if (p < m) { // p = m; // m = 0; // } } if (p > m) cout << endl << p << endl; else cout << endl << m << endl; }

void main() { setlocale(LC_ALL, "ukr"); srand(time(NULL)); const int n = 15; int arr[n], m = 0,p = 0; for (int i = 0; i < n; i++) { arr[i] = rand() % 10  5; cout << arr[i] << " "; } cout << endl; for (int i = 0; i < n; i++) { if (!arr[i]) m=1; if ( arr[i] < 0){ p+=m; m = 0; } } cout << endl << p+m << endl; }