请问这个程序哪出错了?运行不起来唉
//HanioTower.java
import java.io.*;
public class HanioTower
{
public static void main(String[] args)
{
int n=0;
System.out.print( "请输入金片的个数: ");
trt
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
n=Integer.parseInt(br.readLine());
}catch(
IOException ex){}
hanio( 'A ', 'C ', 'B ',n);
}
static void hanio(char from,char to,char temp,int n)
{
System.out.println( "调用hanio( "+from+ ", "+to+ ", "+team+ ", "+n+ ") ");
if(n==1)
System.out.println(from+ "move to "+to);
else
{
hanio(from,temp,to,n-1);
System.out.println(from+ "move to "+to);
hanio(temp,to,from,n-1);
}
}
}
------解决方案--------------------你的程序有三处错误:
1.是try{}catch(){}而不是trt{}catch(){}
2. "System.out.print( "请输入金片的个数: "); "这句话中的最后一个 ") "有问题.不能是中文的符号.
3.System.out.println( "调用hanio( "+from+ ", "+to+ ", "+team+ ", "+n+ ") ");中team是什么东东?应该是temp吧?
全改正以后 可以运行!
答毕,结贴!