首页 > 其他 > 详细

实验四

时间:2019-03-30 20:33:28      阅读:150      评论:0      收藏:0      [点我收藏+]

程序代码:

 

package yanghui;

public class YH {
public static void main(String[]args) {
int i=1;
int yh[]=new int[8];
for(i=0;i<5;i++) {
yh[i]=1;
for(int j=i-1;j>0;j--) {
yh[j]=yh[j-1]+yh[j];

}
for(int j=0;j<=i;j++) {
System.out.print(yh[j]+"\t");
}
System.out.println();
}
}

}

 

 

 

 

实验结果:

     1
   1 1
  1 2 1
 1 3 3 1
1 4 6 4 1

 

心得:

       这次实验中用到了一维数组,还有很多个for循环,其中for循环中的嵌套循环要格外仔细,否则会搞混大括号的匹配以及循环顺序。对于JAVA程序的编写还不够熟练,要多加练习。

 

实验四

原文:https://www.cnblogs.com/1998bmx/p/10628788.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!