How to write the Hanoi algorithm of c #
Most people do not understand the knowledge points of this article "how to write the Hanoi Tower algorithm of c #", so the editor summarizes the following contents, the content is detailed, the steps are clear, and it has a certain reference value. I hope you can get something after reading this article, let's take a look at this article "how to write the Hanoi Tower algorithm of c #".
# include void main () {extern a; extern b; extern c; extern s; void hanno (int,char,char,char); void setNum (int); int n; printf ("Please input the number of dishes:"); scanf ("% d", & n); printf ("The following is moving% d dishes.\ n (% 2d 00)\ n", n Magna); setNum (n) Hanno (nmagedar1);} int a _ int btint c _ poliint _ int _ void setNum (int m) {aqimm;} void hanno (int _ mmah _ char pillar1,char pillar2,char pillar3) {void move (char,char,int); if (m _ makeshift 1) {swatches; move (pillar1,pillar3,s);} else {hanno Hanno (hanno);};} void move (char Xenophore) {if (xanthology) & & a > 0) a Fashi; else if (xtremity jewelry B' & & b > 0) b Mustang; else if (xanthology music C'& c > 0) c Mustave; if (yawning gift A') ahands; else if (yawning gift B') baking; else if (yawning gift C') C++ Printf ("% 3D:% c-- >% c (% 2d% 2d% 2d)\ n".
# gcc hannuota.c-o hannuota
#. / hannuota
Please input the number of dishes: 3
The following is moving 3 dishes...
(300)
1: a-> C (2001)
2: a-> B (11)
3: C-> B (120)
4: a-> C (0 21)
5: B-> A (11)
6: B-> C (1 02)
7: a-> C (0 03)
The above is the content of this article on "how to write the Hanoi algorithm of c #". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.