用JAVA语言编程 求1!+2!+3!+4!+5!+6!+7!+8!+9!+10!.(要求:使用while、do-whi

学习 时间:2026-03-30 20:53:31 阅读:2771
用JAVA语言编程 求1!+2!+3!+4!+5!+6!+7!+8!+9!+10!.(要求:使用while、do-while、for三种语句

最佳回答

彩色的凉面

平常的钢笔

2026-03-30 20:53:31

public class Test{ public static void main(String[] args){ int x = 1; //用于求每个数的阶层 int count = 0,sum = 0; //用于统计1 - 10 阶层的和 int[] m = new int[10]; //用于保存每个阶层的结果,可以自己去打印 //对于这里,没什么好解释的,你自己带值手动跑2次,就知道是什么意思了。 for(int i = 1; i

最新回答共有2条回答

  • 精明的钢铁侠
    回复
    2026-03-30 20:53:31

    public class Test{ public static void main(String[] args){ int x = 1; //用于求每个数的阶层 int count = 0,sum = 0; //用于统计1 - 10 阶层的和 int[] m = new int[10]; //用于保存每个阶层的结果,可以自己去打印 //对于这里,没什么好解释的,你自己带值手动跑2次,就知道是什么意思了。 for(int i = 1; i

上一篇 有没有好听又不难的英文歌 最好是现在比较流行的

下一篇 你认为科学家都是怪人吗?为什么?