- 20
- 0
- 约 4页
- 2017-08-19 发布于河南
- 举报
java1~100阶乘与
姓名: 学号: 班级: 日期:
实验题目
//实验题目
设计过程
设计方法概述
//简单说明你对本上机实验的设计思路
代码
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication4;
import java.math.*;
/**
*
* @author Administrator
*/
public class JavaApplication4 {
public int aa[]=new int [100];
public int b=0;
public void chushihua(){
for(int x=0;x100;x++)
{
aa[x]=x+1;
}
}
public void jiecheng(){
BigInteger cc[]=new BigInteger[100];BigInteger d;BigInteger e;
d=BigInteger.valueOf(0);
for(int x=0;x100;x++)
{
cc[x]=BigInteger.valueOf(aa[x]);
}
for(int x=2;x100;x++)
{
for(int y=2;yaa[x];y++)
{
e=BigInteger.valueOf(y);
cc[x]=cc[x].multiply(e);
}
System.out.println(cc[x]);
}
for(int x=0;x100;x++)
{
d=d.add(cc[x]);
}
System.out.println( );
System.out.println( );
System.out.println(阶乘和是:+d);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
JavaApplication4 bb=new JavaApplication4();
bb.chushihua();bb.jiecheng();
}
}
其他
//其他需要说明的内容;若无,则可不填写。
运行结果
//以贴图的方式填写
小结
//写下本次上机实验你的感受或存在的问题
//可逐条书写
注:请填写报告的蓝颜色处,填写完毕后删除该报告蓝颜色字体处。
原创力文档

文档评论(0)