Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write the Hanoi algorithm of c #

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report