冒泡

int [] arr=new int[]{n}

for(int outer=0; outer<arr.length;outer++)

  {

         for(int inn=outer+1;inn<arr.length;inn++)

            {

                  if(arr[outer]>arr[inn])

      {

                          arr[outer]=arr[outer]+arr[inn];

                          arr[inn]=arr[outer]-arr[inn];

                          arr[outer]=arr[outer]-arr[inn];

      }

            }

  }

posted @ 2013-04-15 23:24  Blue_Dream  阅读(95)  评论(0编辑  收藏  举报