class Solution {
public:
    // Parameters:
    //        numbers:     an array of integers
    //        length:      the length of array numbers
    //        duplication: (Output) the duplicated number in the array number
    // Return value:       true if the input is valid, and there are some duplications in the array number
    //                     otherwise false
    bool duplicate(int numbers[], int length, int* duplication) { //找到的重复数字通过参数duplication传给函数的调用者
        bool pos[length]; //length为数组的长度
        for(int i=0;i<length;i++){
            pos[i]=false;
        }
        bool symbol=false; //symbol为数组中是否有重复数字的标志,也是函数的返回值
        for(int i=0;i<length;i++){
            if(pos[numbers[i]]){
                *duplication=numbers[i];
                symbol=true;
                break;
            }
            else pos[numbers[i]]=true;
        }
        return symbol;
    }
};