/*
找出数组中出现次数超过数组长度一半的数
*/
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char *argv[])
{
int array[]={1,2,3,3,3,3,3,4,5,6};
int A = 0;
int B = 0;
int length = sizeof(array)/sizeof(int);
for(int i=0;i<length;i++)
{
if(B==0)
{
A = array[i];
B = 1;
}
else
{
if(A==array[i])
{
B++;
}
else if(A != array[i])
{
B--;
}
}
}
cout << A << endl;
return 0;
}