classProgram{staticintGetNum(int n,int r){int num =1;// 每一行第一个数是1,第二个数等于前一个数字乘以行数-1,再除以循环的次数 for(int i =1; i <= r; i++)
num = num *(n - i +1)/ i;return num;}staticvoidMain(string[] args){int n =5;// 层数int num;for(int i =0; i < n; i++){for(int j =0; j < n; j++){if(j ==0)for(int k =0; k <=(n - i); k++)
Console.Write(" ");else
Console.Write(" ");
num =GetNum(i, j);if(num !=0)
Console.Write(num.ToString()+" ");}
Console.WriteLine();}
Console.ReadLine();}}