📄 yanghui.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package 杨辉三角的打印;import java.io.*;public class Yanghui{ public static void main(String args[]) { int n,i,j; n=0; System.out.println("Please Input How Many Lines to Print:"); try{BufferedReader br= new BufferedReader (new InputStreamReader(System.in)); n=Integer.parseInt(br.readLine()); }catch(IOException e){} System.out.println("There Are "+n+" Lines:"); int[][] yangNum; yangNum=new int[n+1][n+1]; yangNum[1][1]=1; yangNum[2][1]=1; yangNum[2][2]=1; for(i=3;i<=n;i++) { yangNum[i][1]=1; for(j=2;j<i;j++) { yangNum[i][j]=yangNum[i-1][j]+yangNum[i-1][j-1]; } yangNum[i][i]=1; } for(i=1;i<=n;i++) { for(j=1;j<=i;j++) System.out.print(yangNum[i][j]+"\t"); System.out.println(); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -