回答例のアニメーション

    for(int lastindex=area.length-1; lastindex>0; lastindex--) {
      int maxindex = 0;                       // 先頭の要素が最大値と仮定
      for(int i=1; i<=lastindex; i++) {       // 2番目の要素から最後まで
        if(area[maxindex] < area[i]) {        //   要素の値が最大値より大きい場合
          maxindex = i;                       //     添字を保存
        }                                     //   end if
      }                                       // end for

      int temp = area[maxindex];              // 最大値を一時退避
      area[maxindex] = area[lastindex];       // 最大値のあった要素に最後の要素の値を代入
      area[lastindex] = temp;                 // 最後の要素に退避した値を代入
    }
Step No. 0    Slide No. 0    Message:     

     


Top Page
Mail to:fujimura-java@hc.cc.keio.ac.jp