新手求指导,C++改错,错因“cannot convert parameter 1 from 'char [2]' to 'char'”
#include<iostream>usingnamespacestd;voidhanoi(charx,chary,charz,intn){if(n==1)cout<<"...
#include <iostream>
using namespace std;
void hanoi(char x,char y,char z,int n)
{
if (n==1)
cout <<"1:"<<x<<"→"<<y<<endl;
else
{
hanoi(x,z,y,n-1);
cout <<n<<":"<<x<<"→"<<y<<endl;
hanoi(z,y,x,n-1);
}
}
void main()
{
hanoi("A","B","C",8);
} 展开
using namespace std;
void hanoi(char x,char y,char z,int n)
{
if (n==1)
cout <<"1:"<<x<<"→"<<y<<endl;
else
{
hanoi(x,z,y,n-1);
cout <<n<<":"<<x<<"→"<<y<<endl;
hanoi(z,y,x,n-1);
}
}
void main()
{
hanoi("A","B","C",8);
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询