itmyhome
2013-03-03 13:34:00
java打印杨辉三角
java打印杨辉三角
public static void main(String[] args) { int i, j, n = 8, l, r; int a[] = new int[9]; System.out.println(1); for (i = 1; i <= n; i++) { l = 1; System.out.print(1 + " "); for (j = 1; j <= i; j++) { r = a[j]; a[j] = l + r; /* 每个数是上面两数之和 */ l = r; System.out.print(a[j] + " "); } System.out.println(); } }
运行后截图:
由最代码官方编辑于2014-11-16 10:14:22
猜你喜欢
请下载代码后再发表评论
相关代码
最近下载
微信网友_6982963544330240 LV1
5月7日
wuziayng1232 LV10
2022年11月14日
CaoCaii LV6
2022年6月15日
明123456 LV11
2021年5月27日
大兴西北 LV2
2020年12月13日
mengnan8989 LV22
2018年5月16日
773901419 LV1
2016年10月16日
terryang LV19
2014年1月2日
renwoaoxiangwxk LV1
2013年3月3日
最近浏览
微信网友_6982963544330240 LV1
5月7日
try8023 LV18
1月16日
生米的 LV10
2023年3月3日
myBreaker LV5
2023年1月11日
炫瓶百事可乐 LV1
2022年12月1日
wuziayng1232 LV10
2022年11月14日
CaoCaii LV6
2022年6月15日
uni-code_0123 LV1
2022年6月12日
lwkjchen01
2022年5月7日
暂无贡献等级
mySong LV11
2022年4月7日