import java.io.*;
class Factorial{
try{
int n;
BufferedReader guang=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please input a number!");
n=Integer.parseInt(guang.readLine());
catch ( Exception e)
{ System.out.println(e);
}
public static int factorial(){
if(n==1){
return 1;
}
return n*factorial(n-1);
}
}
}
class Factorial1{
public static void main(String[] args){
Factorial A=new Factorial();
System.out.println("A:"+A.factorial());
}
}
谁帮我看看是什么问题
class Factorial{
try{
int n;
BufferedReader guang=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please input a number!");
n=Integer.parseInt(guang.readLine());
catch ( Exception e)
{ System.out.println(e);
}
public static int factorial(){
if(n==1){
return 1;
}
return n*factorial(n-1);
}
}
}
class Factorial1{
public static void main(String[] args){
Factorial A=new Factorial();
System.out.println("A:"+A.factorial());
}
}
谁帮我看看是什么问题
解决方案 »
- swt菜单设计问题
- 关于图片是否保存至数据库的问题
- SocketException: Unexpected end of file from server这个异常时怎么回事
- B *xx = new B(); java中没有星号运算符吧??
- 程序一共就俩句话,我怎么就不知道哪错了呢??
- jdk的bin里的几个工具是做什么用的?高手进
- 在一个panel中放有按钮,如何在点击按钮的时候也触发panel的某一个事件??
- 180分 !! 正则表达式的简单问题!
- 怎样通过socket读入字符串
- 请问Random类的Random r=new Random()和Random r=new Random(seedValue)有什么区别?
- ((DefaultEditor)JSpinner.getEditor()).getTextField().requestFocusInWindow()有没有替代的方法设置它的光标位置
- ☆◆◆☆ 如何直接在jTable中添加,修改数据并操作在数据库中??
楼主【Tomasea】截止到2008-07-02 15:29:06的历史汇总数据(不包括此帖):
发帖的总数量:0 发帖的总分数:0
结贴的总数量:0 结贴的总分数:0
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:---------------------结分的百分比:---------------------
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
int n;
BufferedReader guang=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please input a number!");
n=Integer.parseInt(guang.readLine());
catch ( Exception e)
{ System.out.println(e);
} 这段扔方法里
int n=0;
try{ BufferedReader guang=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please input a number!");
n=Integer.parseInt(guang.readLine());
catch ( Exception e)
{ System.out.println(e);
}
if(n==1){
return 1;
}
return n*factorial(n-1);
}
}
}
class Factorial1{
public static void main(String[] args){
Factorial A=new Factorial();
System.out.println("A:"+A.factorial());
}
} 不知道是否是楼主要的效果
import java.io.BufferedReader;
import java.io.InputStreamReader;public class Factorial
{
static int n; static
{
try
{
BufferedReader guang = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Please input a number: ");
n = Integer.parseInt(guang.readLine());
}
catch(Exception e)
{
System.out.println(e);
}
} public static int factorial()
{
return factorial(n);
} public static int factorial(int n)
{
if(n == 1 || n == 0)
{
return 1;
} return n * factorial(n - 1);
} public static void main(String[] args)
{
System.out.println("A:" + Factorial.factorial());
}
}
你这个调了没有哦, hoho,你编译一下看看~~~~~~~~~~~~~~~