0102 HW
import javax.swing.JOptionPane;
public class Recursive {
public static void main(String[] arg)
{ String PString=JOptionPane.showInputDialog("幾階層");
int i=Integer.parseInt(PString);
System.out.println(i+" 階層是 "+Recursive.orders(i));
System.exit(0);}
public static int orders(int i){
int n=1;
if (i==0){return 1;}
else if(i>0){ return(orders(i-1)*i);
}
else return 0;}
}
public class Recursive {
public static void main(String[] arg)
{ String PString=JOptionPane.showInputDialog("幾階層");
int i=Integer.parseInt(PString);
System.out.println(i+" 階層是 "+Recursive.orders(i));
System.exit(0);}
public static int orders(int i){
int n=1;
if (i==0){return 1;}
else if(i>0){ return(orders(i-1)*i);
}
else return 0;}
}
0 Comments:
張貼留言
<< Home