经典面试题——找出超过一半的数
摘要:View Code #include <iostream>using namespace std;int A[] = {1,1,5,1,1,2,2,3,1,2,1};int main(){ int i,j; int n = 11; int cal = -1; int t = 0; for(i=0;i<n;i++){ if( i == 0){ cal = A[i]; t = 1; }else{ if(cal != A[i]) t++; ...
阅读全文
posted @ 2012-02-21 16:40
浙公网安备 33010602011771号