diff --git a/Program.cs b/Program.cs index b7183b7..1af4355 100644 --- a/Program.cs +++ b/Program.cs @@ -1,9 +1,168 @@ namespace matrix_3; -class Program -{ - static void Main(string[] args) - { - Console.WriteLine("Hello, World!"); +class Program { + static void Main(string[] args) { + Menu(); + } + + static void Menu() { + Console.Clear(); + int scelta; + int[,] matrix = null; + int[] array = null; + do { + + Console.WriteLine(); + Console.WriteLine("Inserire un'opzione:"); + Console.WriteLine("1. Crea e mostra matrice quadrata"); + Console.WriteLine("2. Somma diagonale secondaria"); + Console.WriteLine("3. Media diagonale secondaria"); + 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()); + + switch (scelta) { + case 0: + break; + case 1: + Console.Clear(); + matrix = CreaMatrice(); + Console.Clear(); + Console.WriteLine("La matrice creata è la seguente:"); + MostraMatrice(matrix); + Pausa(); + break; + case 2: + Console.Clear(); + if (matrix != null) { + Console.WriteLine($"La somma degli elementi della diagonale principale è {SommaMatriceDiagonale2(matrix)}"); + } + else { + Console.WriteLine("È necessario creare la matrice prima di calcolare la somma della diagonale principale."); + } + Pausa(); + break; + case 3: + Console.Clear(); + if (matrix != null) { + Console.WriteLine($"La media degli elementi della diagonale principale è {SommaMatriceDiagonale2(matrix) / matrix.GetLength(0)}"); + } + else { + Console.WriteLine("È necessario creare la matrice prima di calcolare la media della diagonale principale."); + } + Pausa(); + break; + case 4: + Console.Clear(); + if (matrix != null) { + //Console.WriteLine($"La media degli elementi della diagonale principale è {SommaMatriceDiagonale(matrix) / matrix.GetLength(0)}"); + } + else { + Console.WriteLine("È necessario creare la matrice prima di calcolare la media della diagonale principale."); + } + Pausa(); + break; + case 5: + Console.Clear(); + if (matrix != null) { + //Console.WriteLine($"Il prodotto degli elementi della diagonale principale è {ProdottoMatriceDiagonale(matrix)}"); + } + else { + Console.WriteLine("È necessario creare la matrice prima di calcolare il prodotto della diagonale principale."); + } + Pausa(); + break; + case 6: + Console.Clear(); + if (matrix != null) { + //array = MinimoMassimoMatriceDiagonale(matrix, 0); + Console.WriteLine($"Il valore minimo è {array[0]} e si trova in posizione {array[1]},{array[2]}"); + //array = MinimoMassimoMatriceDiagonale(matrix, 1); + Console.WriteLine($"Il valore massimo è {array[0]} e si trova in posizione {array[1]},{array[2]}"); + } + else { + Console.WriteLine("È necessario creare la matrice prima di calcolare il minimo e il massimo della diagonale principale."); + } + Pausa(); + break; + case 7: + Console.Clear(); + if (matrix != null) { + if (true) { + 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 (true) { + 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(); + break; + } + } + while (scelta != 0); + } + + static void Pausa() { + Console.WriteLine("Premere un tasto per continuare. . ."); + Console.ReadKey(); + Console.Clear(); + } + + static int[,] CreaMatrice() { + int dimensione = 0; + Console.Write("Inserire la dimensione della matrice: "); + dimensione = Convert.ToInt32(Console.ReadLine()); + int[,] ritorno = new int[dimensione, dimensione]; + for (int r = 0; r < ritorno.GetLength(0); r++) { + for (int c = 0; c < ritorno.GetLength(1); c++) { + Console.Write($"Inserire l'elemento in posizione {r}, {c}: "); + ritorno[r, c] = Convert.ToInt32(Console.ReadLine()); + Console.WriteLine(); + } + } + return ritorno; + } + static void MostraMatrice(int[,] p_matrice) { + for (int r = 0; r < p_matrice.GetLength(0); r++) { + for (int c = 0; c < p_matrice.GetLength(1); c++) { + Console.Write(p_matrice[r, c] + " "); + } + Console.WriteLine(); + } + } + + static int SommaMatriceDiagonale2(int[,] p_matrice) { + int ritorno = 0; + for (int r = 0; r < p_matrice.GetLength(0); r++) { + ritorno = ritorno + p_matrice[r, p_matrice.GetLength(1) - 1 - r]; + } + return ritorno; } } diff --git a/bin/Debug/net9.0/matrix_3 b/bin/Debug/net9.0/matrix_3 new file mode 100755 index 0000000..7888efa Binary files /dev/null and b/bin/Debug/net9.0/matrix_3 differ diff --git a/bin/Debug/net9.0/matrix_3.deps.json b/bin/Debug/net9.0/matrix_3.deps.json new file mode 100644 index 0000000..bed7e2a --- /dev/null +++ b/bin/Debug/net9.0/matrix_3.deps.json @@ -0,0 +1,23 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v9.0", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v9.0": { + "matrix_3/1.0.0": { + "runtime": { + "matrix_3.dll": {} + } + } + } + }, + "libraries": { + "matrix_3/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + } + } +} \ No newline at end of file diff --git a/bin/Debug/net9.0/matrix_3.dll b/bin/Debug/net9.0/matrix_3.dll new file mode 100644 index 0000000..627c95c Binary files /dev/null and b/bin/Debug/net9.0/matrix_3.dll differ diff --git a/bin/Debug/net9.0/matrix_3.pdb b/bin/Debug/net9.0/matrix_3.pdb new file mode 100644 index 0000000..576c20f Binary files /dev/null and b/bin/Debug/net9.0/matrix_3.pdb differ diff --git a/bin/Debug/net9.0/matrix_3.runtimeconfig.json b/bin/Debug/net9.0/matrix_3.runtimeconfig.json new file mode 100644 index 0000000..b19c3c8 --- /dev/null +++ b/bin/Debug/net9.0/matrix_3.runtimeconfig.json @@ -0,0 +1,12 @@ +{ + "runtimeOptions": { + "tfm": "net9.0", + "framework": { + "name": "Microsoft.NETCore.App", + "version": "9.0.0" + }, + "configProperties": { + "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false + } + } +} \ No newline at end of file diff --git a/obj/Debug/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.cs b/obj/Debug/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.cs new file mode 100644 index 0000000..9e76325 --- /dev/null +++ b/obj/Debug/net9.0/.NETCoreApp,Version=v9.0.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")] diff --git a/obj/Debug/net9.0/apphost b/obj/Debug/net9.0/apphost new file mode 100755 index 0000000..7888efa Binary files /dev/null and b/obj/Debug/net9.0/apphost differ diff --git a/obj/Debug/net9.0/matrix_3.AssemblyInfo.cs b/obj/Debug/net9.0/matrix_3.AssemblyInfo.cs new file mode 100644 index 0000000..90b1d5f --- /dev/null +++ b/obj/Debug/net9.0/matrix_3.AssemblyInfo.cs @@ -0,0 +1,22 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("matrix_3")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2a271926848667bcddcead0052bc6ea47fdebd86")] +[assembly: System.Reflection.AssemblyProductAttribute("matrix_3")] +[assembly: System.Reflection.AssemblyTitleAttribute("matrix_3")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/obj/Debug/net9.0/matrix_3.AssemblyInfoInputs.cache b/obj/Debug/net9.0/matrix_3.AssemblyInfoInputs.cache new file mode 100644 index 0000000..855d6f9 --- /dev/null +++ b/obj/Debug/net9.0/matrix_3.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +7aca69c8efa80f19ce3e2ea6d36183ecb1eed8e8b6ea588310183037a98ae435 diff --git a/obj/Debug/net9.0/matrix_3.GeneratedMSBuildEditorConfig.editorconfig b/obj/Debug/net9.0/matrix_3.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 0000000..24e0747 --- /dev/null +++ b/obj/Debug/net9.0/matrix_3.GeneratedMSBuildEditorConfig.editorconfig @@ -0,0 +1,15 @@ +is_global = true +build_property.TargetFramework = net9.0 +build_property.TargetPlatformMinVersion = +build_property.UsingMicrosoftNETSdkWeb = +build_property.ProjectTypeGuids = +build_property.InvariantGlobalization = +build_property.PlatformNeutralAssembly = +build_property.EnforceExtendedAnalyzerRules = +build_property._SupportedPlatformList = Linux,macOS,Windows +build_property.RootNamespace = matrix_3 +build_property.ProjectDir = /home/Verde/git/matrix_3/ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = +build_property.EffectiveAnalysisLevelStyle = 9.0 +build_property.EnableCodeStyleSeverity = diff --git a/obj/Debug/net9.0/matrix_3.GlobalUsings.g.cs b/obj/Debug/net9.0/matrix_3.GlobalUsings.g.cs new file mode 100644 index 0000000..8578f3d --- /dev/null +++ b/obj/Debug/net9.0/matrix_3.GlobalUsings.g.cs @@ -0,0 +1,8 @@ +// +global using global::System; +global using global::System.Collections.Generic; +global using global::System.IO; +global using global::System.Linq; +global using global::System.Net.Http; +global using global::System.Threading; +global using global::System.Threading.Tasks; diff --git a/obj/Debug/net9.0/matrix_3.assets.cache b/obj/Debug/net9.0/matrix_3.assets.cache new file mode 100644 index 0000000..58c36d3 Binary files /dev/null and b/obj/Debug/net9.0/matrix_3.assets.cache differ diff --git a/obj/Debug/net9.0/matrix_3.csproj.CoreCompileInputs.cache b/obj/Debug/net9.0/matrix_3.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..a74b6f0 --- /dev/null +++ b/obj/Debug/net9.0/matrix_3.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +b91e41113936300931501220e93d8f3c36671cd57b6f666e13424bea8ff185b1 diff --git a/obj/Debug/net9.0/matrix_3.csproj.FileListAbsolute.txt b/obj/Debug/net9.0/matrix_3.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..c5b933f --- /dev/null +++ b/obj/Debug/net9.0/matrix_3.csproj.FileListAbsolute.txt @@ -0,0 +1,14 @@ +/home/Verde/git/matrix_3/obj/Debug/net9.0/matrix_3.GeneratedMSBuildEditorConfig.editorconfig +/home/Verde/git/matrix_3/obj/Debug/net9.0/matrix_3.AssemblyInfoInputs.cache +/home/Verde/git/matrix_3/obj/Debug/net9.0/matrix_3.AssemblyInfo.cs +/home/Verde/git/matrix_3/obj/Debug/net9.0/matrix_3.csproj.CoreCompileInputs.cache +/home/Verde/git/matrix_3/bin/Debug/net9.0/matrix_3 +/home/Verde/git/matrix_3/bin/Debug/net9.0/matrix_3.deps.json +/home/Verde/git/matrix_3/bin/Debug/net9.0/matrix_3.runtimeconfig.json +/home/Verde/git/matrix_3/bin/Debug/net9.0/matrix_3.dll +/home/Verde/git/matrix_3/bin/Debug/net9.0/matrix_3.pdb +/home/Verde/git/matrix_3/obj/Debug/net9.0/matrix_3.dll +/home/Verde/git/matrix_3/obj/Debug/net9.0/refint/matrix_3.dll +/home/Verde/git/matrix_3/obj/Debug/net9.0/matrix_3.pdb +/home/Verde/git/matrix_3/obj/Debug/net9.0/matrix_3.genruntimeconfig.cache +/home/Verde/git/matrix_3/obj/Debug/net9.0/ref/matrix_3.dll diff --git a/obj/Debug/net9.0/matrix_3.dll b/obj/Debug/net9.0/matrix_3.dll new file mode 100644 index 0000000..627c95c Binary files /dev/null and b/obj/Debug/net9.0/matrix_3.dll differ diff --git a/obj/Debug/net9.0/matrix_3.genruntimeconfig.cache b/obj/Debug/net9.0/matrix_3.genruntimeconfig.cache new file mode 100644 index 0000000..9956292 --- /dev/null +++ b/obj/Debug/net9.0/matrix_3.genruntimeconfig.cache @@ -0,0 +1 @@ +8a058181ce150492e15146c95d1d41dcdde08d81048650011ed65a5eb0104163 diff --git a/obj/Debug/net9.0/matrix_3.pdb b/obj/Debug/net9.0/matrix_3.pdb new file mode 100644 index 0000000..576c20f Binary files /dev/null and b/obj/Debug/net9.0/matrix_3.pdb differ diff --git a/obj/Debug/net9.0/ref/matrix_3.dll b/obj/Debug/net9.0/ref/matrix_3.dll new file mode 100644 index 0000000..4eaabed Binary files /dev/null and b/obj/Debug/net9.0/ref/matrix_3.dll differ diff --git a/obj/Debug/net9.0/refint/matrix_3.dll b/obj/Debug/net9.0/refint/matrix_3.dll new file mode 100644 index 0000000..4eaabed Binary files /dev/null and b/obj/Debug/net9.0/refint/matrix_3.dll differ