Helper cs-1
Helper cs-1
u
using System.Collections.Generic;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ArrDoMemadi
{
internal class Helper
{
public static void ArrFill(int[,] arr)
{
for (int i = 0; i < arr.GetLength(0); i++)
{
for (int j = 0; j < arr.GetLength(1); j++)
{
Console.WriteLine("enter the next number: ");
arr[i, j] = int.Parse(Console.ReadLine());
}
}
}
public static void ArrRandomFill(int[,] arr)
{
Random rnd = new Random();
for (int i = 0; i < arr.GetLength(0); i++)
{
for (int j = 0; j < arr.GetLength(1); j++)
{
arr[i, j] = rnd.Next(0, 100);
}
}
}
public static void PrintArr(int[,] arr)
{
for (int i = 0; i < arr.GetLength(0); i++)
{
for (int j = 0; j < arr.GetLength(1); j++)
{
Console.Write("{0,3}",arr[i, j]);
}
Console.WriteLine();
}
}
public static bool IsSquare(int[,] arr)
{
if (arr.GetLength(0) != arr.GetLength(1))
{
return false;
}
return true;
}
public static bool IsSymmetric(int[,] arr)
{
int rows = arr.GetLength(0);
int cols = arr.GetLength(1);
if (rows == cols)
{
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols / 2; j++)
{
if (arr[i, j] != arr[i, cols - 1 - j] || arr[i, j] != arr[rows - 1 - i, j])
{
return false;
}
}
}
return true;
}
return false;
}
public static void PrintMainDiagonal(int[,] arr)
{
if (arr.GetLength(0) == arr.GetLength(1))
{
Console.WriteLine("numbers in main diagonal are: ");
for (int i = 0; i < arr.GetLength(1); i++)
{
if (i == arr.GetLength(0) - 1)
{
Console.Write(arr[i, i]);
Console.WriteLine();
}
else
{
Console.Write(arr[i, i] + ", ");
}
}
}
}
public static void printSecondaryDiagonal(int[,] arr)
{
if (arr.GetLength(0) == arr.GetLength(1))
{
int j = 0;
Console.WriteLine("numbers in Secondary diagonal are: ");
for (int i = arr.GetLength(0) - 1; i >= 0; i--)
{
if (j == arr.GetLength(1) - 1)
{
Console.Write(arr[i,j]);
Console.WriteLine();
}
else
{
Console.Write(arr[i, j] + ", ");
}
j++;
}
}
}
public static int sumRow(int[,] arr,int row)
{
int sum = 0;
Console.Write("the sum of row {0} is: ",row);
return result;
}
}
}