---
title: "汉诺塔"
author: "cfeers"
date: "2010-09-15T07:47:50Z"
tags: []
categories: ["编程语言"]
slug: "untitled"
draft: false
lastmod: "2010-09-15T07:47:50Z"
id: 763486
url: "https://cfeers.iteye.com/blog/763486"
---

递归写的汉诺塔，C预言。

 

#include&lt;stdio.h&gt;  
main()  
{  
 int n;  
 scanf("%d",&n);  
  hanoi(n,"A","B","C");  
 }  
   
 hanoi(int n,char a,char b,char c)  
   {  
    if(n&gt;0)  
     {  
       hanoi(n-1,a,c,b);  
        printf("move dish %d from pile %d",n,a,b,c);  
        hanoi(n-1,c,b,a); }  
 }