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
猜你喜欢
请下载代码后再发表评论


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日

生米的 LV10
3月3日
myBreaker LV5
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日
luozf1990 LV3
2022年1月6日
郴州安仁小霸王
2021年12月29日
暂无贡献等级