Counting repeated elements in an integer array

前端 未结 13 1296
挽巷
挽巷 2020-11-27 08:02

I have an integer array crr_array and I want to count elements, which occur repeatedly. First, I read the size of the array and initialize it with numbers read

13条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 08:26

    for (int i = 0; i < x.length; i++) {
    
        for (int j = i + 1; j < x.length; j++) {
    
            if (x[i] == x[j]) {
                y[i] = x[i];
                times[i]++;
            }
    
        }
    
    }
    

提交回复
热议问题