How to change the value of array elements

前端 未结 7 2022
情歌与酒
情歌与酒 2020-12-21 10:57
int A = 300;
int B = 400;
int C = 1000;
int D = 500;

int []abcd = {A,B,C,D};
Arrays.sort(abcd);   // the sequence of array elements will be {300, 400, 500,1000}
         


        
7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-21 11:33

    Don't sort them. Put them in one array, have a second array initialized to all zeros, and count how many items are greater than or equal to each element. Then just transfer these counts back to the variables.

提交回复
热议问题