int[,] m = new int[TB_3.RowCount,TB_3.ColumnCount];
for (int i = 0; i < TB_3.RowCount; i++)
{
for (int j = 0; j < TB_3.ColumnCount; j++)
{
m[i, j] = Convert.ToInt32(TB_3[j, i].Value);
}
}
for (int i = 0; i < TB_3.RowCount; i++)
{
for (int k = 0; k < TB_3.ColumnCount; k++)
{
double s = 0;
for (int j = 0; j < TB_3.ColumnCount-k; j++)
{
s += m[i, k + j];
}
double sum = s / (j + 1);
TB_2[k, i].Value = sum;
}
}