#include <iostream>

int main() {
    
    int data[] = {1, 1, -1, 1, 1, 1, -1, 1, 1};
    int size = sizeof(data) / sizeof(data[0]);

    int max = 0;
    int checknum = 0;
    
    for(int i = 0; i<size; i++) 
    {
        if(data[i] != -1) 
        {
            checknum++;
        } 
        else 
        {
            if(max < checknum)
                max = checknum;
            checknum = 0;
        }
        
    }

    if(max < checknum) max = checknum;

    printf("max = %d",max);
    
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: