diff --git a/Program.cs b/Program.cs index b8b6978..f2d4a01 100644 --- a/Program.cs +++ b/Program.cs @@ -1,4 +1,6 @@ -namespace matrix_2; +using System.Reflection.Metadata; + +namespace matrix_2; class Program { static void Main(string[] args) { @@ -20,6 +22,8 @@ class Program { Console.WriteLine("4. Media diagonale principale"); Console.WriteLine("5. Prodotto diagonale principale"); Console.WriteLine("6. Valore minimo e massimo diagonale principale"); + Console.WriteLine("7. Trova zeri sulla diagonale principale"); + Console.WriteLine("8. Cerca sulla diagonale principale"); Console.WriteLine("0. Esci"); Console.Write("Scelta: "); scelta = Convert.ToInt32(Console.ReadLine()); @@ -85,6 +89,37 @@ class Program { } Pausa(); break; + case 7: + Console.Clear(); + if (matrix != null) { + if (TrovaDiagonale(matrix, 0)) { + Console.WriteLine("Sulla diagonale principale sono presenti degli zeri"); + } + else { + Console.WriteLine("Sulla diagonale principale non sono presenti degli zeri"); + } + } + else { + Console.WriteLine("È necessario creare la matrice prima di cercare gli zeri sulla diagonale principale."); + } + Pausa(); + break; + case 8: + Console.Clear(); + if (matrix != null) { + Console.Write("Inserire un numero da cercare: "); + if (TrovaDiagonale(matrix, Convert.ToInt32(Console.ReadLine()))) { + Console.WriteLine("Elemento trovato"); + } + else { + Console.WriteLine("Elemento non trovato"); + } + } + else { + Console.WriteLine("È necessario creare la matrice prima di cercare un elemento sulla diagonale principale."); + } + Pausa(); + break; default: Console.WriteLine("Opzione non valida."); Pausa(); @@ -120,7 +155,7 @@ class Program { Random rnd = new Random(); for (int r = 0; r < p_matrice.GetLength(0); r++) { for (int c = 0; c < p_matrice.GetLength(1); c++) { - p_matrice[r, c] = rnd.Next(6); //TODO: rimettere il valore a 101 + p_matrice[r, c] = rnd.Next(101); } } } @@ -170,4 +205,14 @@ class Program { return ritorno; } + + static bool TrovaDiagonale(int[,] p_matrice, int p_DaTrovare) { + bool ritorno = false; + for (int r = 0; r < p_matrice.GetLength(0) && !ritorno; r++) { + if (p_matrice[r, r] == p_DaTrovare) { + ritorno = true; + } + } + return ritorno; + } } diff --git a/bin/Debug/net9.0/matrix_2.dll b/bin/Debug/net9.0/matrix_2.dll index 5b6180d..fec6a6e 100644 Binary files a/bin/Debug/net9.0/matrix_2.dll and b/bin/Debug/net9.0/matrix_2.dll differ diff --git a/bin/Debug/net9.0/matrix_2.pdb b/bin/Debug/net9.0/matrix_2.pdb index c3491e8..f3b4193 100644 Binary files a/bin/Debug/net9.0/matrix_2.pdb and b/bin/Debug/net9.0/matrix_2.pdb differ diff --git a/obj/Debug/net9.0/matrix_2.AssemblyInfo.cs b/obj/Debug/net9.0/matrix_2.AssemblyInfo.cs index 008dc35..eb045e0 100644 --- a/obj/Debug/net9.0/matrix_2.AssemblyInfo.cs +++ b/obj/Debug/net9.0/matrix_2.AssemblyInfo.cs @@ -13,10 +13,10 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("matrix_2")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+282e5ed6576673e17566281d70cd78d712d58a3a")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+9441f2232224090ad4976d49bcfdbeb7d01779f6")] [assembly: System.Reflection.AssemblyProductAttribute("matrix_2")] [assembly: System.Reflection.AssemblyTitleAttribute("matrix_2")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] -// Generated by the MSBuild WriteCodeFragment class. +// Generato dalla classe WriteCodeFragment di MSBuild. diff --git a/obj/Debug/net9.0/matrix_2.AssemblyInfoInputs.cache b/obj/Debug/net9.0/matrix_2.AssemblyInfoInputs.cache index 65ec05d..d5fc491 100644 --- a/obj/Debug/net9.0/matrix_2.AssemblyInfoInputs.cache +++ b/obj/Debug/net9.0/matrix_2.AssemblyInfoInputs.cache @@ -1 +1 @@ -5c574530e7a1f84a8ba8807f4f033310b4dab2123c9302f06e61373058a1456f +0e56d238097473adb0a30716e289d969291c614c61b91e302df23fb47e627318 diff --git a/obj/Debug/net9.0/matrix_2.dll b/obj/Debug/net9.0/matrix_2.dll index 5b6180d..fec6a6e 100644 Binary files a/obj/Debug/net9.0/matrix_2.dll and b/obj/Debug/net9.0/matrix_2.dll differ diff --git a/obj/Debug/net9.0/matrix_2.pdb b/obj/Debug/net9.0/matrix_2.pdb index c3491e8..f3b4193 100644 Binary files a/obj/Debug/net9.0/matrix_2.pdb and b/obj/Debug/net9.0/matrix_2.pdb differ diff --git a/obj/Debug/net9.0/ref/matrix_2.dll b/obj/Debug/net9.0/ref/matrix_2.dll index e4d45df..8600c25 100644 Binary files a/obj/Debug/net9.0/ref/matrix_2.dll and b/obj/Debug/net9.0/ref/matrix_2.dll differ diff --git a/obj/Debug/net9.0/refint/matrix_2.dll b/obj/Debug/net9.0/refint/matrix_2.dll index e4d45df..8600c25 100644 Binary files a/obj/Debug/net9.0/refint/matrix_2.dll and b/obj/Debug/net9.0/refint/matrix_2.dll differ