輸入數(shù)據(jù)有多組,每組1個整數(shù)n,表示Hanoi塔的階數(shù)。
將每次移動(move)按照以下格式輸出:%2d. Move disk %d from %c to %c\n
上述格式中第一個整數(shù)表示第幾次移動,第二個整數(shù)表示移動第幾個圓盤,后兩個字符表示將圓盤從哪個塔座移至哪個塔座上。每組輸出后面輸出一個空行。
1 2 3
1. Move disk 1 from X to Z 1. Move disk 1 from X to Y 2. Move disk 2 from X to Z 3. Move disk 1 from Y to Z 1. Move disk 1 from X to Z 2. Move disk 2 from X to Y 3. Move disk 1 from Z to Y 4. Move disk 3 from X to Z 5. Move disk 1 from Y to X 6. Move disk 2 from Y to Z 7. Move disk 1 from X to Z