返回列表 發帖
package zzzzzzzzzzzzz;

public class zzzzzzzzzzz {

        public static void main(String[] args) {
                // TODO 自動產生的方法 Stub
                int y  ;
                int[] a = {2, 4, 3, 5, 7, 6, 9, 1};
               
                 for(int i=0;i<a.length-1;i++)
                 {
                         for(int j=0;j<a.length-i-1;j++)
                         {
                                 if(a[j]>a[j+1])
                                 {
                                         y=a[j];
                                         a[j]=a[j+1];
                                         a[j+1]=y;
                                 }
                         }
                         for (int k=0;k<a.length;k++)
                         {
                                 System.out.print(a[k]+" ");
                         }
                         System.out.println();
                 }
        }

}

TOP

返回列表