/******************************************************************************
Online C# Compiler.
Code, Compile, Run and Debug C# program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
using System;
class HelloWorld {
public static void Array()
{
Random rd = new Random();
int[,] Abc = new int[7,7];
//لكل سطر
for (int i = 0; i < Abc.GetLength(0); i++)
{
//لكل عامود
for (int M = 0; M <Abc.GetLength(1); M++)
{
Abc[i, M]=rd.Next(10);
}
}
Print(Abc);
Console.WriteLine("Totalrow:{0}",Totalrow(Abc, Abc.GetLength(0)-1));
Console.WriteLine("Totalcol:{0}", TotalCol(Abc, 0));
}
public static void Print(int[,] S)
{
Console.Clear();
Console.WriteLine("Matrix");
//لكل سطر
for (int i = 0; i < S.GetLength(0); i++)
{
//لكل عامود
for (int k = 0; k < S.GetLength(1); k++)
{
Console.Write("{0}|", S[i, k]);
}
//Console.WriteLine();
//for (int k = 0; k < S.GetLength(1); k++)
//{
// Console.Write("{0}|", "-");
//}
Console.WriteLine();
}
}
public static int Totalrow(int[,] S,int row)
{
//لكل عامود
int Total = 0;
for (int i = 0; i < S.GetLength(1); i++)
Total += S[row,i];
return Total;
}
public static int TotalCol(int[,] S, int col)
{
//لكل سطر
int Total = 0;
for (int i = 0; i < S.GetLength(0); i++)
Total += S[i,col];
return Total;
}
static void Main() {
Console.WriteLine("Hello World");
Array();
}
}