---
title: "C++用递归解决汉诺塔问题（续）"
author: "yunchow"
date: "2009-05-19T12:16:10Z"
tags: ["C", "C#", "C++"]
categories: ["编程语言"]
slug: "c"
draft: false
lastmod: "2009-05-19T12:16:10Z"
id: 391068
url: "https://yunchow.iteye.com/blog/391068"
---

```c

#include <iostream.h>
using namespace std;

void move(int top,int n,char src,char dst,char tmp)
{
	if(1==n)	
		cout << top << ":" << src << "-->" << dst << endl;
	else
	{
		move(top,n-1,src,tmp,dst);
		move(top+n-1,1,src,dst,tmp);
		move(top,n-1,tmp,dst,src);
	}
}
int main(void)
{
	move(1,3,'A','B','C');
	return 0;
}

```