我在用xcode写hanoi塔程序,用函数的递归调用时出现了了conflicting types for,程序无法运行
```nclude
int main()
{
void hanoi(int n,char x,char y,char z);
int m;
printf("The number of diskes:");
scanf("%d",&m);
printf("move %d deshes:\n",m);
hanoi(m,'A','B','C');
return 0;
}
void hanoi(int n,char x,char y,char z)
{
void move(char a,char b);
if(n==1)
move(x,z);
else{
hanoi(n-1,x,y,z);
move(x,z);
hanoi(n-1,y,x,z);
}
}
void move(char a,char b)
{
printf("%c-->%c\n",a,b);
}
仅供参考,望采纳~
出现原因:引用在声明之前
#include<stdio.h>
void hanoi(int n,char x,char y,char z);
int main()
{
int m;
printf("The number of diskes:");
scanf("%d",&m);
printf("move %d deshes:\n",m);
hanoi(m,'A','B','C');
return 0;
}
void move(char a,char b)
{
printf("%c-->%c\n",a,b);
}
void hanoi(int n,char x,char y,char z)
{
if(n==1)
move(x,z);
else{
hanoi(n-1,x,y,z);
move(x,z);
hanoi(n-1,y,x,z);
}
}