递归请解释一下 [英] Recursion please explain this

查看:83
本文介绍了递归请解释一下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,有人在这里发布了河内代码塔...我现在在我的编程课中有这个任务..我显然可以接受这个代码并修改它但我只是想了解它是如何工作的我不能把它变成不知道这里发生了什么。有人可以向我解释当程序进入河内时会发生什么(nDisks - 1,pegA,pegC,pegB);那个功能?切换pegA,B和C顺序的目的是什么?这是整个代码..

展开 | 选择 | Wrap | 行号

解决方案

让我建议你得到现在摆脱这段代码,写下你自己的代码。 TSDN不支持抄袭,你的老师可能会因为作弊而给你一个明智的感觉。


你理解程序如何工作的最好方法是写上它你自己。想出解决TOH难题的一般解决方案,然后将该解决方案变成算法。


我是否有人建议我计划将此代码转入?我发布了代码,询问是否有人可以向我解释这是如何实际工作的。然后在获得理解后我可以编写自己的代码..感谢帮助虽然



我显然可以使用此代码并对其进行修改但我只是想了解这是如何工作的我不知道这是怎么回事



由此,我认为你的意思是你会把它转过来,但直到你理解它为止。对于我的任何误解和/或粗暴感到抱歉。


hey someone posted towers of hanoi code on here.. I have this assignment in my programming class now.. I obviously can take this code and modify it but i just want to understand how this works I cant turn this in not knowing whats going on here. Could someone please explain to me what is going on when the program enters hanoi (nDisks - 1, pegA, pegC, pegB); that function? What is the purpose for switching the order of pegA, B, and C? this is the entire code..

Expand|Select|Wrap|Line Numbers

解决方案

Let me suggest that you get rid of this code, now, and write your own. TSDN doesn''t support plagiarism, and your teacher might get wise as give you a 0 for cheating.

The best way for you to understand how a program works is to write it on your own. Come up with a general solution for solving a TOH puzzle, and then turn that solution into an algorithm.


Did I anywhere suggest that I was planning on turning this code in? I posted the code asking if someone can explain to me how this is actually working. Then after gaining an understanding I can write my own code.. thanks for the help though


I obviously can take this code and modify it but i just want to understand how this works I cant turn this in not knowing whats going on here.

By this, I thought you meant you would be turning it in, but not until you understood it. Sorry for any misunderstanding and/or harshness on my part.


这篇关于递归请解释一下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆