0

dram a pascal s triangle

please write a code to draw pascal triangle 1 1 1 1 2 1 1 3 3 1

29th Sep 2016, 9:43 AM
Arpit Farkya
Arpit Farkya - avatar
1 Resposta
+ 1
public void DrawPascalTriangle(int depth){ int[,] tab=new int[depth,depth]; for(int i=0;i<depth;i++){ tab[0,i]=1; Console.Write("1 "); tab[i,i]=1; for(int j=1;j<i;j++){ tab[j,i]=tab[j-1,i]+tab[j,i-1]; Console.Write(tab[j,i]+" "); } Console.WriteLine("1"); } } I think you should think about algorithms by yourself, it's more fun this way.
25th Oct 2016, 10:15 PM
Michał Isalski
Michał Isalski - avatar