課程
/后端開發(fā)
/Java
/Java入門第一季(IDEA工具)升級版
要求我們輸入n的部分詳細(xì)說明一下
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("請輸入基數(shù):");
int n=input.nextInt();
while(n>=i)
? ? ?product*=i;
? ? i++;
}
System.out.println(n+"的階乘為:"+product);
慕粉1649252996 提問者
舉報
0基礎(chǔ)萌新入門第一課,從Java環(huán)境搭建、工具使用、基礎(chǔ)語法開始
4 回答請問“n/=10”跟“n=n/10”有什么區(qū)別
1 回答1、分別用while和for完成輸入整數(shù)n,輸出1+2+..+n的和;
4 回答10*1.5^(n-1)怎么表達(dá)?
4 回答設(shè)置常量為char型,然后輸出System.out.println(SEXM+'\n'+SEXF) 輸出是數(shù)字
6 回答用java語言編寫:計算并輸出一個整數(shù)各位數(shù)字之和??比如4321,得出10。
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
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("請輸入基數(shù):");
int n=input.nextInt();
while(n>=i)
{
? ? ?product*=i;
? ? i++;
}
System.out.println(n+"的階乘為:"+product);
}
}