发布网友 发布时间:2022-04-22 16:27
共1个回答
热心网友 时间:2023-10-21 15:13
int[] array = new int[5];
int[] power={3,2,3,3,5};
for (int i = 0; i < array.length; i++) {
array[i]=(int)(Math.random()*100);
}
for (int i = 0;i < power.length;i++){
for(int j = i;j < power.length;j++){
if (power[i] > power[j]){
int arr = array[i];
array[i] = array[j];
array[j] = arr;
int pow = power[i];
power[i] = power[j];
power[j] = pow;
}else if(power[i] == power[j]){
if(array[i] > array[j]){
int arr = array[i];
array[i] = array[j];
array[j] = arr;
int pow = power[i];
power[i] = power[j];
power[j] = pow;
}
}
}
}