前提:端点的数为1. 每个数等于它上方两数之和。 每行数字左右对称,由1开始逐渐变大。 第n行的数字有n项。 第n行数字和为2n-1。 第n行的m个数可表示为 C(n-1,m-1),即为从n-1个不同元素中取m-1个元素的组合数。 第n行的第m个数和第n-m+1个数相等 ,为组合数性质之一。 每个数 ...
分类:
编程语言 时间:
2016-10-07 01:43:07
阅读次数:
225
代码如下: public class YanghuiTest {public static void main(String[] args) { int yanghui[][]=new int[10][];//创建二维数组 //遍历二维数组的第一层 for(int i=0;i<yanghui.len ...
分类:
其他好文 时间:
2016-10-05 17:30:10
阅读次数:
136
通过控制输出的格式,实现1、左下杨辉三角(普通型)2、左上三角,3、金字塔形杨辉三角的输出。 ...
分类:
其他好文 时间:
2016-09-28 19:09:09
阅读次数:
109
FJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N <= 10) in a certain order and then sum adjacent numbers t ...
分类:
其他好文 时间:
2016-09-20 19:36:19
阅读次数:
220
1 import java.util.Scanner; 2 import java.util.InputMismatchException; 3 public class Text2 4 { 5 public static void main(String[] args) 6 { 7 System. ...
分类:
其他好文 时间:
2016-09-18 08:52:58
阅读次数:
98
5.从键盘上输入一个正整数n,请按照以下五行杨辉三角形的显示方式, 输出杨辉三角形的前n行。请采用循环控制语句来实现。 (三角形腰上的数为1,其他位置的数为其上一行相邻两个数之和。) 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 Scanner sc=new ...
分类:
编程语言 时间:
2016-09-17 19:04:43
阅读次数:
136
Scanner sc=new Scanner(System.in); System.out.println("请输入一个正整数;"); int ss=sc.nextInt(); int[][]m=new int[ss][ss]; for(int i=0;i<ss;i++) { for(int j=0 ...
分类:
其他好文 时间:
2016-09-17 14:47:10
阅读次数:
177