import javax.swing.*;
public class FactorialTest {
public static void main (String args[])
{
int n;
String s=(String)JOptionPane.showInputDialog(null,"请输入一个整数","1到n的阶乘",
JOptionPane.PLAIN_MESSAGE,null,null,null);
n=Integer.parseInt(s);
long i=1,j=1,k=1;
while (j<=n)
{
k=k*j;
System.out.println(j+"!="+k);
j++;
}
}
}
第7周作业1-循环大战while
最新推荐文章于 2021-09-22 09:50:55 发布