1. 程式人生 > >劍指offer陣列中只出現一次的數字

劍指offer陣列中只出現一次的數字

class Solution {
public:
    void FindNumsAppearOnce(vector<int> data,int* num1,int *num2) {
        int flag = 1;
        int number = 0;
        int length = data.size();
        vector <int> ivec;
        for (int i = 0; i !=length ; i++)
        {
            for( int j = 0; j!=length ;j++)
                {
                    if
(i==j) continue; if( data[i] == data[j]) { flag = 0; } } if ( flag == 1 && number ==0) { *num1 = data[i]; flag = 0
; number = 1; } if (flag == 1 && number ==1) { *num2 = data[i]; break; } flag = 1; } } };