java對double數(shù)組排序示例分享
更新時間:2014年03月05日 14:52:05 作者:
這篇文章主要介紹了java對double數(shù)組排序示例,代碼簡單,下面我們直接上代碼,需要的朋友可以參考下
復(fù)制代碼 代碼如下:
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 數(shù)字排序
* @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;
}
}
}
/**
* 這里是過濾掉整數(shù)的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]);
}
}
}
}
相關(guān)文章
利用spring-data-redis實現(xiàn)incr自增的操作
這篇文章主要介紹了利用spring-data-redis實現(xiàn)incr自增的操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-11-11