import java.io.*;
public class ConsoleReader
{
private String temp;
BufferedReader reader;
public ConsoleReader()
{
reader = new BufferedReader(new InputStreamReader(System.in));
}
public int getInt()
{
try
{
temp = reader.readLine();
}
catch (IOException ex)
{
ex.printStackTrace();
}
return Integer.parseInt(temp);
}
}
//æ°ç»å®ç°æ¨è¾ä¸è§
import com.mfg.console.ConsoleReader;
public class YanHui
{
int[][] a;
public YanHui()
{
ConsoleReader console=new ConsoleReader();
System.out.print("请è¾å
¥è¦æ±çæ¨è¾ä¸è§ç级æ°ï¼");
int n=console.getInt();
a=new int[n][];
for(int i=0;i a[i]=new int[i+1];
//计ç®æ¨è¾ä¸è§
a[0][0]=1;
for(int i=1;i {
a[i][0]=1;
for(int j=1;j {
a[i][j]=a[i-1][j-1]+a[i-1][j];
}
a[i][a[i].length-1]=1;
}
//æå°æ¨è¾ä¸è§
for(int i=0;i {
for (int j = 0; j < a[i].length; j++)
System.out.print(a[i][j]+" ");
System.out.println();
}
}
public static void main(String[] args)
{
YanHui yanHui1 = new YanHui();
}
}
温馨提示:答案为网友推荐,仅供参考