Type Find(Type* a, int N) //a代表数组,N代表数组长度 { Type candidate; int nTimes, i; for(i = nTimes = 0; i < N; i++) { if(nTimes == 0) { candidate = a[i], nTimes = 1; } else { if(candidate == a[i]) nTimes++; else nTimes--; } } return candidate; }