- package airthmatic;
- public class demo10 {
- public static void main(String[] args) {
- double n[]={9,1.2,5,3.2,1.1};
- orderNum(n);
- }
- /**
- * double 和 int 数字排序
- * @param n
- */
- public static void orderNum(double []n){
- for(int i=0;i<n.length-1;i++){
- for(int j=0;j<n.length-1-i;j++){
- double temp=0;
- if(n[j]>n[j+1]){
- temp=n[j+1];
- n[j+1]=n[j];
- n[j]=temp;
- }
- }
- }
- /**
- * 这里是过滤掉整数的double类型
- */
- for(int i=0;i<n.length;i++){
- int temp=(int)n[i];
- if(n[i]%temp==0){
- System.out.println(temp);
- }else{
- System.out.println(n[i]);
- }
- }
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/1704201512282.html
来源: http://www.codesnippet.cn/detail/1704201512282.html