課程
/后端開發
/Java
/Java入門第一季(IDEA工具)升級版
要求我們輸入n的部分詳細說明一下
2017-04-03
源自:Java入門第一季(IDEA工具)升級版 7-1
正在回答
import java.util.Scanner;
public class Lei {
public static void main(String args[])
{
int i=1;
int product=1;
Scanner input =new Scanner(System.in);
System.out.print("請輸入基數:");
int n=input.nextInt();
while(n>=i)
? ? ?product*=i;
? ? i++;
}
System.out.println(n+"的階乘為:"+product);
慕粉1649252996 提問者
舉報
0基礎萌新入門第一課,從Java環境搭建、工具使用、基礎語法開始
4 回答請問“n/=10”跟“n=n/10”有什么區別
1 回答1、分別用while和for完成輸入整數n,輸出1+2+..+n的和;
4 回答10*1.5^(n-1)怎么表達?
4 回答設置常量為char型,然后輸出System.out.println(SEXM+'\n'+SEXF) 輸出是數字
6 回答用java語言編寫:計算并輸出一個整數各位數字之和??比如4321,得出10。
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-04-03
import java.util.Scanner;
public class Lei {
public static void main(String args[])
{
int i=1;
int product=1;
Scanner input =new Scanner(System.in);
System.out.print("請輸入基數:");
int n=input.nextInt();
while(n>=i)
{
? ? ?product*=i;
? ? i++;
}
System.out.println(n+"的階乘為:"+product);
}
}