using System;
namespace App {
internal class Program {
private static void Main() {
var a = new[,] {{1, 2, 3}, {1, 2, 3}, {1, 2, 3}};
for (var j = 0; j <= a.GetUpperBound(1); j++) {
if (j % 2 == 0)
a[0, j] = ColumnSum(j, ref a);
else
a[0, j] = ColumnProduct(j, ref a);
}
for (var i = 0; i <= a.GetUpperBound(0); i++) {
for (var j = 0; j <= a.GetUpperBound(1); j++)
Console.Write("{0} ", a[i, j]);
Console.WriteLine();
Console.ReadLine();
public static int ColumnSum(int column, ref int[,] a) {
var sum = 0;
sum += a[i, column];
return sum;
public static int ColumnProduct(int column, ref int[,] a) {
var p = 1;
p *= a[i, column];
return p;
using System;
namespace App {
internal class Program {
private static void Main() {
var a = new[,] {{1, 2, 3}, {1, 2, 3}, {1, 2, 3}};
for (var j = 0; j <= a.GetUpperBound(1); j++) {
if (j % 2 == 0)
a[0, j] = ColumnSum(j, ref a);
else
a[0, j] = ColumnProduct(j, ref a);
}
for (var i = 0; i <= a.GetUpperBound(0); i++) {
for (var j = 0; j <= a.GetUpperBound(1); j++)
Console.Write("{0} ", a[i, j]);
Console.WriteLine();
}
Console.WriteLine();
Console.ReadLine();
}
public static int ColumnSum(int column, ref int[,] a) {
var sum = 0;
for (var i = 0; i <= a.GetUpperBound(0); i++) {
sum += a[i, column];
}
return sum;
}
public static int ColumnProduct(int column, ref int[,] a) {
var p = 1;
for (var i = 0; i <= a.GetUpperBound(0); i++) {
p *= a[i, column];
}
return p;
}
}
}