diff --git a/src/jp/co/cis/other/Hanoi.java b/src/jp/co/cis/other/Hanoi.java index 7bff639..a214db3 100644 --- a/src/jp/co/cis/other/Hanoi.java +++ b/src/jp/co/cis/other/Hanoi.java @@ -1,7 +1,7 @@ package jp.co.cis.other; public class Hanoi { - + public static void main(String[] args) { Hanoi hanoi = new Hanoi(); hanoi.exec(); @@ -11,10 +11,10 @@ public static void main(String[] args) { * ハノイの塔の移動させる円盤と塔を出力します */ public void exec() { - + move(5, "START", "GOAL", "WORK"); } - + /** * 円盤を移動させます * @param enban 移動させる円盤の枚数 @@ -23,21 +23,22 @@ public void exec() { * @param work 作業用の棒 */ private void move(int enban, String from, String to, String work) { - + if(enban > 0) { // 一番下でないなら続ける - + // (1)一番下以外を作業用の棒に移動させる - - + move(enban-1 , from , work , to ); + // (2)一番下をGOALに移動させる System.out.println(enban + "番の円盤を" + from + "から" + to + "に移動させる"); - + // (3)(1)で移動させた円盤を棒を入れ替えて移動させる + move(enban-1 , work , to , from ); + + } + + - } - - - } } diff --git a/src/jp/co/cis/sort/BubbleSort.java b/src/jp/co/cis/sort/BubbleSort.java deleted file mode 100644 index 619c4da..0000000 --- a/src/jp/co/cis/sort/BubbleSort.java +++ /dev/null @@ -1,19 +0,0 @@ -package jp.co.cis.sort; - -/** - * バブルソートで並び替えるクラスです。 - * - */ -public class BubbleSort { - - /** - * 配列の値を小さい順に並び替えた結果を返却します。 - * @param ary - * @return - */ - public int[] sort(int[] ary) { - // TODO バブルソートで並び替える処理を実装してください。 - return ary; - } - -} diff --git a/src/jp/co/cis/sort/SelectionSort.java b/src/jp/co/cis/sort/SelectionSort.java deleted file mode 100644 index 1cbcbcb..0000000 --- a/src/jp/co/cis/sort/SelectionSort.java +++ /dev/null @@ -1,19 +0,0 @@ -package jp.co.cis.sort; - -/** - * 選択ソートで配列の値を並び替えるクラスです。 - * - */ -public class SelectionSort { - - /** - * 配列の値を小さい順に並び替えた結果を返却します。 - * @param ary - * @return - */ - public int[] sort(int[] ary) { - // TODO 選択ソートで並び替える処理を実装してください。 - return ary; - } - -}