Найти сумму ненулевых элементов матрицы. Ошибки в программе - C#
Формулировка задачи:
Программа не работает, а какие ошибки допущены понять не могу
int main()
{
setlocale (LC_ALL, "RUS");
int g;
int h;
printf ("Введите количество строк ");
scanf ("%d", &g);
printf ("Введите количество столбцов ");
scanf ("%d", &h);
int i, j, b;
int [g],
for(i=0; i<g; i++)
for(j=0; j<h; j++)
{
printf ("Введите элемент матрицы A ["i+1"]["j+1"] ");
scanf (("A+i)+j);
}
for(i=0; i<g; i++)
{
for(j=0; j<h; j++)
{cout.width(g);
printf ("A[i][j]");
}
printf("end");
getch();
}
Решение задачи: «Найти сумму ненулевых элементов матрицы. Ошибки в программе»
textual
Листинг программы
int number,rez,i,j;
rez = 0;
int[,] mass = new int[100, 100];
Random rnd = new Random();
while (true)
{
Console.Write("number = ");
try
{
number = int.Parse(Console.ReadLine());
for (i=0;i<number; i++)
{
for (j=0;j< number;j++)
{
mass[i, j] = rnd.Next(50)-6;
Console.Write(mass[i, j] + "\t");
}
Console.WriteLine();
}
for (i=0;i< number;i++)
{
for (j=0;j< number;j++)
{
if (mass[i,j] > 0 )
{
rez += mass[i, j];
}
}
}
Console.WriteLine(rez);
Console.ReadLine();
return;
}
catch (Exception error)
{
Console.WriteLine("Enter number pls" + error.Message);
}