编辑代码

#include <stdio.h>

int find_one(int num[], int length){
    int temp[length];
    //int temp[length]={};
    for(int i=0;i<length;i++)
        temp[i]=0;
    
    for(int i=0; i<length; i++){
        temp[num[i]]++;
        if(temp[num[i]]>(length/2)){
            return num[i];
        }
    }
    return -1;
}

int main () {
    //JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。 
	//printf("Hello JSRUN!   \n\n         - from C .");
	int length = 8;
    int test[]={0,5,5,3,5,7,5,5};
    int b = find_one(test, length);
    printf("%d", b);
    return 0;
}