实验内容:采用一维数组输出等腰三角形的杨辉三角
实验程序:
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
121
1331
14641
实验结论: 此次实验调试过程中出现很多问题,一开始不知道如何编写,后面通过借鉴其他同学的程序,才知道怎么编写,基础知识不足,在今后的日子里要好好学习
原文:https://www.cnblogs.com/baiyunchao/p/10635771.html