int main() {
    long i, N;
    long* Array;
    scanf("%ld", &N);
    Array = (long*) malloc(sizeof(long) * N);
    i = 0;
    int count = 0;
    long test = 0;
    while (i < N) {
        scanf("%ld", &Array[i]);
        i++;
    }
    //check simplest cases
    if (N == 1) {
        count = 1;
    } else {
        count = majority_element(Array, N);
//        maj = majority_element_sort(Array, N);
    }

    printf("%d\n", count);
    free(Array);
}
示例#2
0
int main (void) {

    int a[9] = {1, 1, 1, 1, 1, 12, 3, 56};
    majority_element(a,9);
    return 0;
}