Tower of Hanoi

Source: Internet
Author: User
# Include <stdio. h> void hannuota (int n, char a, char B, char c) {/* if it is one plate, move the disk from A to C; otherwise, move the n-1 on column A to Column B with C, move the plate on column A to column C, and move the n-1 on column B) A to C. */If (n = 1) {printf ("Move the plate numbered % d directly from % C pillar to % C pillar \ n", N,, c);} else {hannuota (n-1, A, C, B); printf ("Move the plate numbered % d directly from % C pillar to % C pillar \ n ", n, a, B); hannuota (n-1, B, A, c) ;}} void main () {int N; char character = 'a '; char CH2 = 'B'; char CH3 = 'C'; printf ("Enter the number of plates to move:"); scanf ("% d", & N ); hannuota (n, 'A', 'B', 'C ');}

 

Tower of Hanoi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.