c语言新手求助
#include<stdio.h>void main()
{
void hanoi(int n, char one, char two, char three);
int n;
printf("please input your dish :");
scanf_s("%d", &n);
hanoi(n, 'x', 'y', 'z');
}
void hanoi(int n, char one, char two, char three)
{
void move(char x, char y);
if (n == 1)
{
move(one,three);
}
else
{
hanoi(n - 1, one, three, two);//在vs2019 three对应的值不是'y'但从xjy的视频里貌似它就是等于y
move(one, three);
hanoi(n - 1, two, one, three);
}
}
void move(char x, char y)
{
printf("%c-->%c\n", x, y);
}
//n=3时
x-->z
x-->y
z-->y
x-->z
y-->x
y-->z
x-->z
本帖最后由 clay_sun 于 2021-4-20 16:52 编辑
看看互相交流下
页:
[1]