// plateau.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
void plateau(int arry[],int n)
{
int count,max_num,max_count;
count=1;
max_count=1;
max_num=arry[0];
for(int i=1;i<n;i++)
{
if(arry[i]==arry[i-1])
count++;
else
{
if(count>max_count)
{
max_count=count;
max_num=arry[i-1];
if(max_count>=(n-i))
{
break;
}
count=1;
}
else
{
count=1;
}
}
}//for
if(i==n && count>max_count)
{
max_count=count;
max_num=arry[n-1];
}
printf("max_count=%d,max_num=%d\n",max_count,max_num);
}
int main(int argc, char* argv[])
{
int a[]={1,2,3,3,3,4,4,4,4,4,5,5,5,5,5,5,6,7,7,8};
plateau(a,sizeof(a)/sizeof(int));
printf("Hello World!\n");
return 0;
}
/*
max_count=6,max_num=5
Hello World!
Press any key to continue
*/