/*
Rūdolfs Čābūts
Praktiskais darbs 5
https://www.onlinegdb.com/online_csharp_compiler

*/

using System;

public class Program
{
static void Main()
{
//1. Uzdevums

int [,] array1 = {
{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12}};

for (int i = 0; i < array1.GetLength(0); i++)
{
for (int j = 0; j < array1.GetLength(1); j++)
{
Console.Write(array1[i, j] + "\t");
}
}
Console.WriteLine();

//2. Uzdevums

Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
int [][] array2 = new int[3][];
array2[0] = new int[] {1, 2, 3, 4};
array2[1] = new int[] {5};
array2[2] = new int[] {6, 7};

for (int i = 0; i < array2.Length; i++)
{
for (int j = 0; j < (array2[i]).Length; j++)
{
Console.WriteLine(array2[i][j]);
}
}


//3. Uzdevums

Console.WriteLine();
Console.WriteLine();
Console.WriteLine();

int [,] array3 = {
{1, 2, 3, 4, 5},
{6, 7, 8, 9, 10},
{11, 12, 13, 14, 15},
{16, 17, 18, 19, 20}};


for (int i = 0; i < array3.GetLength(0); i++)
{
int rowSum = 0;

for (int j = 0; j < array3.GetLength(1); j++)
{
rowSum += array3[i, j];
}
Console.WriteLine($"Row {i + 1}: {rowSum}");
}

//4. Uzdevums


int [][] array4 = new int[3][];
array4[0] = new int[] {1, 2, 3, 4};
array4[1] = new int[] {5};
array4[2] = new int[] {6, 7};



bool atrasts = false;

do
{
Console.WriteLine("Ievadi kadu skaitli kas varetu but masiva:");
int skaitlis = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < array4.Length; i++)
{
for (int j = 0; j < (array4[i]).Length; j++)
{
if (array4[i][j] == skaitlis)
{
Console.WriteLine($"Skaitlis {skaitlis} atrodas rinda {i}, kolona {j}");
atrasts = true;
}

}
}

}
while (atrasts == false);


//5. Uzdevums

Random rnd = new Random();

int rndNum1 = rnd.Next(0, 10);
int rndNum2 = rnd.Next(0, 10);
int rndNum3 = rnd.Next(0, 10);
int rndNum4 = rnd.Next(0, 10);
int rndNum5 = rnd.Next(0, 10);
int rndNum6 = rnd.Next(0, 10);
int rndNum7 = rnd.Next(0, 10);
int rndNum8 = rnd.Next(0, 10);
int rndNum9 = rnd.Next(0, 10);
int rndNum10 = rnd.Next(0, 10);
int rndNum11 = rnd.Next(0, 10);

int [][] array5 = new int[4][];
array5[0] = new int[] {rndNum1, rndNum2, rndNum3, rndNum4};
array5[1] = new int[] {rndNum5, rndNum6, rndNum7,};
array5[2] = new int[] {rndNum8, rndNum9};
array5[3] = new int[] {rndNum10, rndNum11};


for (int i = 0; i < array5.Length; i++)
{
Array.Sort(array5[i]);
Console.Write($"Rinda {i}: \n");

for (int j = 0; j < (array5[i]).Length; j++)
{
Console.WriteLine(array5[i][j] + " ");
}
Console.WriteLine();
}









}
}
