C++暴力递归相关题目
#include<iostream>
#include<vector>
#include<string>
#include<list>
#include<algorithm>
#include<stack>
using namespace std;
void func(int i, string start, string end, string other)
{
if (i == 1)
{
cout << "Move 1 from" << start << "to" << end << endl;
}
else
{
func(i - 1, start, other, end);
cout << "Move" << i << "from" << start << "to" << end << endl;
func(i - 1, other, end, start);
}
}
void hanoi(int n)
{
if (n > 0)
{
func(n, "左", "右", "中");
}
}
void process(string str, int i)
{
if (i == str.length())
{
cout << str << endl;
return;
}
process(str, i + 1);
char tmp =