/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
#include <cstdlib>
#include <ctime>
#define MASS_SIZE 10
int myfunc(int* a);
int main()
{
int x = 0;
int a[MASS_SIZE];
std::srand(std::time(nullptr));
for (size_t i = 0; i < MASS_SIZE; i++)
{
a[i] = std::rand()%15;
std::cout << a[i] << " ";
}
std::cout << std::endl << std::endl;
x = myfunc(a);
std::cout << "x = " << x << std::endl;
return 0;
}
int myfunc(int* a)
{
int x = 0;
for (size_t i = 0; i < MASS_SIZE; i++)
{
for (size_t j = i; j < MASS_SIZE; j++)
{
if (a[j] != a[i])
{
if (j - i > x)
{
x = j - i;
}
i = j - 1;
break;
}
}
}
return x;
}