資源簡介
原創#########
matlab遞歸實現漢諾塔m函數文件
壓縮包中含有兩個文件hannuota.m和hanoi.m
其中,hannuota.m無動畫演示,調用格式為:
>>hannuota(5,'A','B','C')
hanoi.m有動態演示漢諾塔功能,是在hannuota.m的基礎上實現,調用格式為:
>>hanoi(5)

代碼片段和文件信息
function?hannuota(nta1ta2ta3)
%漢諾塔
if?n==1
????fprintf(‘%c-->%c\n‘ta1ta3);
else
????hannuota(n-1ta1ta3ta2);
????fprintf(‘%c-->%c\n‘ta1ta3);
????hannuota(n-1ta2ta1ta3);
end??
end
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3511??2010-06-09?20:28??hanoi.m
?????文件????????202??2010-06-09?20:42??hannuota.m
?????文件????????222??2010-06-09?20:49??說明.txt
-----------?---------??----------?-----??----
?????????????????3935????????????????????3
- 上一篇:物體在空間中的運動軌跡預測
- 下一篇:D-S證據理論融合代碼
評論
共有 條評論