主题:我是个新手,帮帮忙看看这个是什么意思
#include <iostream>
using namespace std;
int main()
{void hanoi(int n,char one,char two,char three);
int m;
cout<<"intput the number of diskes:";
cin>>m;
cout<<<"the steps of moving"<<m<<"disks:"<<endl;
hanoi(m,'A','B','C');
return 0;
}
void hanoi(int n,char one,char two,char three);//将n个盘从one借助two移到three
{void move(char x,char y);
if(n==1) move(one,three);
else {hanoi(n-1,one,three,two);
move(one,three);
hanoi(n-1,two,one,three);
}
}
viod move(char x,char y)
{cout<<x<<--^<<y<<endl;
}
倒数第6行有什么作用啊?
using namespace std;
int main()
{void hanoi(int n,char one,char two,char three);
int m;
cout<<"intput the number of diskes:";
cin>>m;
cout<<<"the steps of moving"<<m<<"disks:"<<endl;
hanoi(m,'A','B','C');
return 0;
}
void hanoi(int n,char one,char two,char three);//将n个盘从one借助two移到three
{void move(char x,char y);
if(n==1) move(one,three);
else {hanoi(n-1,one,three,two);
move(one,three);
hanoi(n-1,two,one,three);
}
}
viod move(char x,char y)
{cout<<x<<--^<<y<<endl;
}
倒数第6行有什么作用啊?