0
dram a pascal s triangle
please write a code to draw pascal triangle 1 1 1 1 2 1 1 3 3 1
1 Odpowiedź
+ 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.