0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

概要

c#で、なでしこ、やってみた。
c#な、なでしこ、見つけたので、msbuildでコンパイルしてみた。
練習問題やってみた。

練習問題

ハノイの塔を解け。

参考にしたページ

サンプルコード


●円盤移動(SRCからDESへ)
 「{SRC}から{DES}へ移動」と表示


●ハノイ(円盤数をSRCからDESへTMPで)
 もし、円盤数=1ならば
  SRCからDESへ円盤移動
 もし、円盤数が2以上ならば
  (円盤数-1)をSRCからTMPへDESでハノイ
  SRCからDESへ円盤移動
  (円盤数-1)をTMPからDESへSRCでハノイ


3を「A」から「C」へ「B」でハノイ


実行結果

>cnako2 hanoi.nako
AからCへ移動
AからBへ移動
CからBへ移動
AからCへ移動
BからAへ移動
BからCへ移動
AからCへ移動

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?