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?

スミレ畑、やってみた。 その5

Posted at

概要

日本語プログラミング言語、スミレ畑、見つけたので、やってみた。
練習問題やってみた。

練習問題

ハノイの塔を書け。

写真

image.png

サンプルコード

【値:整数】だけ【塔:文字列の配列】を、ハノイする手順
 値 > 0なら
  値 - 1だけ{塔(1), 塔(3), 塔(2)}をハノイする
  値 &「番の円盤を、」& 塔(1) &「から」& 塔(2) &「へ移動」& 改行を出力する
  値 - 1だけ{塔(2), 塔(1), 塔(3)}をハノイする
 そして
終わり

3だけ{「A」,「B」,「C」}をハノイする

実行結果

1番の円盤を、AからBへ移動
2番の円盤を、AからCへ移動
1番の円盤を、CからAへ移動
3番の円盤を、AからBへ移動
1番の円盤を、BからCへ移動
2番の円盤を、BからAへ移動
1番の円盤を、AからBへ移動

以上。

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?