美文网首页
冒泡排序

冒泡排序

作者: Winterfell_Z | 来源:发表于2018-06-10 22:42 被阅读1次
public class MapPaoSort{
        public static void main(String []args){
                int a[]=new int{1,2,3,4};
                for(int i=0;i<a.length-1;i++){
                         for(int j=0; j<a.length-1-i; j++ ){
                                 if(a[j]>a[j+1]){
                                          int temp = a[j];
                                           a[j] = a[j+1];
                                           a[j+1] = temp;
                                  }
                          }
                 } 
        }
}

相关文章

网友评论

      本文标题:冒泡排序

      本文链接:https://www.haomeiwen.com/subject/zkwqeftx.html