- 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;
- }
寻找水王
最新推荐文章于 2021-06-20 17:36:41 发布