import java.util.Arrays;
public class hhh {
public static int[] transform(int num[])
{int t=0;
for(int i=0;i<num.length;i++){
if(num[i]%2==0){
for(int j=i+1;j<num.length;j++){
if(num[j]%2!=0){
t=num[j];
num[j]=num[i];
num[i]=t;
break;
}
}
}
}
return num;
}
public static void main(String[] args){
int ary[]={1,2,3,4,5,6};
System.out.println(Arrays.toString(transform(ary)));
}
代码如上