bool compare(const void * a, const void * b){ return *(int *)a <= *(int *)b; } bool IsContinues(int number[], int length){ if(number == NULL || length <1) return false; qsort(number,length, sizeof(int),compare); int numberofzero =0; int cur = 0; while(cur < length && number[cur] == 0){ ++cur; ++numberofzero; } int small = cur, big = cur+1; int gap = 0; while(big < length){ if(number[small] == number[big]) return false; gap += number[big] - number[small] - 1; small = big; ++big; } return gap <= numberofzero ; }