/*
Veidoja: Gustavs Skripa
Grupa: 110
Praktiskais darbs 5
izmantotais compiler: https://www.programiz.com
*/
using System;

class Program
{
static void Main()
//1uzdevums
{
int[,] masivs1 = {
{1,2,3,4},
{5,6,7,8},
{9,10,11,12}
};
for (int i = 0; i < masivs1.GetLength(0); i++)
{
for (int j = 0; j < masivs1.GetLength(1); j++)
Console.Write(masivs1[i, j] + " ");
Console.WriteLine();
}

Console.WriteLine();
//2uzdevums
int[][] masivs2 = {
new int[] {1,2},
new int[] {3,4,5},
new int[] {6}
};
for (int i = 0; i < masivs2.Length; i++)
{
for (int j = 0; j < masivs2[i].Length; j++)
Console.Write(masivs2[i][j] + " ");
Console.WriteLine();
}

Console.WriteLine();
//3uzdevums
int[,] masivs3 = {
{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 < masivs3.GetLength(0); i++)
{
int summa = 0;
for (int j = 0; j < masivs3.GetLength(1); j++)
summa += masivs3[i, j];
Console.WriteLine("Rindas " + (i + 1) + " summa: " + summa);
}

Console.WriteLine();
//4uzdevums
int[][] masivs4 = {
new int[] {1,5,9},
new int[] {2,4},
new int[] {7,8,10,12}
};
Console.Write("Ievadi skaitli: ");
int sk = int.Parse(Console.ReadLine());
bool atrasts = false;
for (int i = 0; i < masivs4.Length; i++)
{
for (int j = 0; j < masivs4[i].Length; j++)
{
if (masivs4[i][j] == sk)
{
Console.WriteLine($"Atrasts rinda {i}, kolonna {j}");
atrasts = true;
}
}
}
if (!atrasts) Console.WriteLine("Nav atrasts");

Console.WriteLine();
//5uzdevums
int[][] masivs5 = {
new int[] {5,2,9},
new int[] {8,1},
new int[] {3,7,4}
};
for (int i = 0; i < masivs5.Length; i++)
Array.Sort(masivs5[i]);
for (int i = 0; i < masivs5.Length; i++)
{
for (int j = 0; j < masivs5[i].Length; j++)
Console.Write(masivs5[i][j] + " ");
Console.WriteLine();
}
}
}