分割错误来了 #包括 #包括 #包括 void main() { int n; 空塔(int n、char from、char to、char aux); clrsc(); printf(“河内塔项目”); printf(“\n\n输入磁盘总数:”); scanf(“%d”,n);塔(n,'A','C','B'); getch(); } 空塔(int n、char from、char to、char aux) { 如果(n==1) { printf(“\n将磁盘1从%c peg移动到%c peg”,从,到); 返回; } 塔(n-1,从,辅助,到); printf(“\n将磁盘%d从%c peg移动到%c peg”,n,from,to); 塔(n-1,辅助,至,自); }

分割错误来了 #包括 #包括 #包括 void main() { int n; 空塔(int n、char from、char to、char aux); clrsc(); printf(“河内塔项目”); printf(“\n\n输入磁盘总数:”); scanf(“%d”,n);塔(n,'A','C','B'); getch(); } 空塔(int n、char from、char to、char aux) { 如果(n==1) { printf(“\n将磁盘1从%c peg移动到%c peg”,从,到); 返回; } 塔(n-1,从,辅助,到); printf(“\n将磁盘%d从%c peg移动到%c peg”,n,from,to); 塔(n-1,辅助,至,自); },c,turbo-c++,C,Turbo C++,将scanf(“%d”,n)替换为scanf(“%d”,n),将指针传递到scanf应将结果放入的位置。使用 scanf(“%d”和“&n”) 而不是 scanf(“%d”,n) 因为它需要变量n到scanf函数的地址来存储值。 因此,该地址是通过&n指定的。请单击编辑链接并正确设置问题的格式。还可以添加实际问题、可能的错误消息等。您可以在预览中看到问题的外观,请在发布前检查。编译器会给您一条错误消息。所以请把它包括在你的问题中。 #include<stdio.h> #includ

scanf(“%d”,n)
替换为
scanf(“%d”,n)
,将指针传递到
scanf
应将结果放入的位置。

使用

scanf(“%d”和“&n”)

而不是

scanf(“%d”,n)

因为它需要变量n到scanf函数的地址来存储值。
因此,该地址是通过&n指定的。

请单击编辑链接并正确设置问题的格式。还可以添加实际问题、可能的错误消息等。您可以在预览中看到问题的外观,请在发布前检查。编译器会给您一条错误消息。所以请把它包括在你的问题中。
#include<stdio.h> 
#include<conio.h>
#include<stdlib.h>

void main() 
{   
  int n;
  void towers(int n,char from, char to,char aux); 
  clrscr();
  printf("\n\t\t PROGRAM FOR TOWERS OF HANOI"); 
  printf("\n\nEnter The Total number of Disks : "); 
  scanf("%d",n);    towers(n,'A','C','B'); 

  getch();
} 
void towers(int n,char from,char to, char aux)
{ 
  if(n==1)
  {     
        printf("\nMove disk 1 from %c peg to %c peg",from,to);  
        return; 
  } 
  towers(n-1,from,aux,to); 
  printf("\n Move disk %d from %c peg to %c peg",n,from,to); 
  towers(n-1,aux,to,from);
}