Task Description
河內塔遞迴版
請運用遞迴求出河內塔步驟。(會檢查fuction是否用遞迴)
河內塔規則如下:

Hint
hnr.h
打上 function header 以及相關的設定。void hnr(int n, char A, char B, char C);
hnr.c
撰寫程式碼後對應上傳。#include "hnr.h"void hnr(int n, char A, char B, char C) { / add your code /}
main.c
這個檔案無法更改也無須上傳。123456789 #include <stdio.h>#include "hnr.h" int main() { int n; scanf("%d", &n); hnr(n, 'A', 'B', 'C'); return 0;}
Input Format
測試n為有幾個盤子(環)。
Output Format
請運用遞迴算出河內塔所有步驟並印出。
Sample Input
1 2
Sample Output
123 盤子從A移到B盤子從A移到C盤子從B移到C