如何在一个textbox里,怎么显示杨辉三角
private void textBox3_TextChanged(object sender, EventArgs e)
{
string Row = this.textBox1.Text;
int trangleRows = int.Parse(Row);
int[][] trangle = new int[trangleRows][];
for (int row = 0; row < trangleRows; row++)
{
trangle[row] = new int[row + 1];
for (int col = 0; col <= row; col++)
{
if (row == 0 && col == 0)
{
trangle[0][0] = 1;
}
else
{
if (col == 0 || col == row)
trangle[row][col] = 1;
else
trangle[row][col] = trangle[row - 1][col] + trangle[row - 1][col - 1];
}
}
}
foreach (int[] colitem in trangle)
{
foreach (int rowitem in colitem)
{
Console.Write("{0} ", rowitem);
}
Console.WriteLine();
}
如何显示呢
private void textBox3_TextChanged(object sender, EventArgs e)
{
string Row = this.textBox1.Text;
int trangleRows = int.Parse(Row);
int[][] trangle = new int[trangleRows][];
for (int row = 0; row < trangleRows; row++)
{
trangle[row] = new int[row + 1];
for (int col = 0; col <= row; col++)
{
if (row == 0 && col == 0)
{
trangle[0][0] = 1;
}
else
{
if (col == 0 || col == row)
trangle[row][col] = 1;
else
trangle[row][col] = trangle[row - 1][col] + trangle[row - 1][col - 1];
}
}
}
foreach (int[] colitem in trangle)
{
foreach (int rowitem in colitem)
{
Console.Write("{0} ", rowitem);
}
Console.WriteLine();
}
如何显示呢