selectSort

来源:互联网 发布:cpda数据分析师 假 编辑:程序博客网 时间:2024/05/29 03:11

publicstaticvoidselectSort(int[]a){

      intminIndex=0;

      inttemp=0;

      if((a==null)||(a.length==0)) { return; }

      for(inti=0;i<a.length-1;i++){

          minIndex=i;

          for(intj=i+1;j<a.length;j++){

              if(a[j]<a[minIndex]){

                  minIndex=j;

               }

           }

          if(minIndex!=i) {

              temp=a[i];

              a[i]=a[minIndex];

              a[minIndex]=temp;

           }

       }

0 0