Using System;
class Program
{
static void Main()
{
var random = new Random(DateTime.Now.Millisecond);
int n = 5;
int k;
var c = new int[n, n];
var b = new int[n];
Console.WriteLine("C:");
for (var i = 0; i < n; i++)
{
for (var j = 0; j < n; j++)
{
c[i, j] = random.Next(0, 9);
Console.Write(c[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
for(int j = 0; j < n; j++) {
k = 0;
for(int i = 0; i < n; i++)
if (c[i, j]==0) k++;
b[j] = k;
}
Console.WriteLine("B:");
for(int i = 0; i < n; i++)
Console.Write(b[i] + " ");
Console.WriteLine();
Console.ReadKey();
}
}
Пример:
C:
3 5 1 3 0
1 6 4 1 7
5 2 5 1 2
4 6 3 0 3
2 3 8 0 7
B:
0 0 0 2 1