diff --git a/Program.cs b/Program.cs index 6d9cad9..3521471 100644 --- a/Program.cs +++ b/Program.cs @@ -1,9 +1,77 @@ namespace matrix_1_variante; -class Program -{ - static void Main(string[] args) - { - Console.WriteLine("Hello, World!"); +class Program { + static void Main(string[] args) { + MostraMinimoMatrice(MinimoMatrice(CreaMatrice())); + } + static int[,] CreaMatrice() { + int righe = 0, colonne = 0; + Console.Write("Inserire le righe della matrice: "); + righe = Convert.ToInt32(Console.ReadLine()); + Console.Write("Inserire le colonne della matrice: "); + colonne = Convert.ToInt32(Console.ReadLine()); + int[,] ritorno = new int[righe, colonne]; + RiempiMatriceRandom(ritorno); + return ritorno; + } + + static void RiempiMatriceRandom(int[,] p_matrice) { + 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(101); + } + } + } + + static int[,] MinimoMatrice(int[,] p_matrice) { + int min = int.MaxValue; + + for (int r = 0; r < p_matrice.GetLength(0); r++) { + for (int c = 0; c < p_matrice.GetLength(1); c++) { + if (p_matrice[r, c] < min) { + min = p_matrice[r, c]; + } + } + } + + return TrovaMatrice(p_matrice, min); + } + + static int[,] TrovaMatrice(int[,] p_matrice, int p_DaTrovare) { + int[,] ritorno = new int[p_matrice.GetLength(0), p_matrice.GetLength(1)]; + RiempiMatriceMax(ritorno); + + for (int r = 0; r < p_matrice.GetLength(0); r++) { + for (int c = 0; c < p_matrice.GetLength(1); c++) { + if (p_matrice[r, c] == p_DaTrovare) { + ritorno[r, c] = p_DaTrovare; + } + } + } + return ritorno; + } + + static void RiempiMatriceMax(int[,] p_matrice) { + for (int r = 0; r < p_matrice.GetLength(0); r++) { + for (int c = 0; c < p_matrice.GetLength(1); c++) { + p_matrice[r, c] = int.MaxValue; + } + } + } + static void MostraMinimoMatrice(int[,] p_matrice) { + bool trovato = false; + + for (int r = 0; r < p_matrice.GetLength(0); r++) { + for (int c = 0; c < p_matrice.GetLength(1); c++) { + if (p_matrice[r, c] != int.MaxValue) { + if (!trovato) { + Console.WriteLine($"Il valore minimo è {p_matrice[r, c]} e si trova nelle posizioni:"); + trovato = true; + } + Console.WriteLine($"{r}, {c}"); + } + } + } } } diff --git a/bin/Debug/net9.0/matrix_1_variante b/bin/Debug/net9.0/matrix_1_variante new file mode 100755 index 0000000..65d2b3d Binary files /dev/null and b/bin/Debug/net9.0/matrix_1_variante differ diff --git a/bin/Debug/net9.0/matrix_1_variante.deps.json b/bin/Debug/net9.0/matrix_1_variante.deps.json new file mode 100644 index 0000000..9b0c85a --- /dev/null +++ b/bin/Debug/net9.0/matrix_1_variante.deps.json @@ -0,0 +1,23 @@ +{ + "runtimeTarget": { + "name": ".NETCoreApp,Version=v9.0", + "signature": "" + }, + "compilationOptions": {}, + "targets": { + ".NETCoreApp,Version=v9.0": { + "matrix_1_variante/1.0.0": { + "runtime": { + "matrix_1_variante.dll": {} + } + } + } + }, + "libraries": { + "matrix_1_variante/1.0.0": { + "type": "project", + "serviceable": false, + "sha512": "" + } + } +} \ No newline at end of file diff --git a/bin/Debug/net9.0/matrix_1_variante.dll b/bin/Debug/net9.0/matrix_1_variante.dll new file mode 100644 index 0000000..4157cd7 Binary files /dev/null and b/bin/Debug/net9.0/matrix_1_variante.dll differ diff --git a/bin/Debug/net9.0/matrix_1_variante.pdb b/bin/Debug/net9.0/matrix_1_variante.pdb new file mode 100644 index 0000000..f474ddb Binary files /dev/null and b/bin/Debug/net9.0/matrix_1_variante.pdb differ diff --git a/bin/Debug/net9.0/matrix_1_variante.runtimeconfig.json b/bin/Debug/net9.0/matrix_1_variante.runtimeconfig.json new file mode 100644 index 0000000..b19c3c8 --- /dev/null +++ b/bin/Debug/net9.0/matrix_1_variante.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..65d2b3d Binary files /dev/null and b/obj/Debug/net9.0/apphost differ diff --git a/obj/Debug/net9.0/matrix_1_variante.AssemblyInfo.cs b/obj/Debug/net9.0/matrix_1_variante.AssemblyInfo.cs new file mode 100644 index 0000000..bc25eaf --- /dev/null +++ b/obj/Debug/net9.0/matrix_1_variante.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_1_variante")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+536e6e5457247eb799c9709fa968f33f70c7d500")] +[assembly: System.Reflection.AssemblyProductAttribute("matrix_1_variante")] +[assembly: System.Reflection.AssemblyTitleAttribute("matrix_1_variante")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/obj/Debug/net9.0/matrix_1_variante.AssemblyInfoInputs.cache b/obj/Debug/net9.0/matrix_1_variante.AssemblyInfoInputs.cache new file mode 100644 index 0000000..170290c --- /dev/null +++ b/obj/Debug/net9.0/matrix_1_variante.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +01871b8f3d99b94fd01d8d8ce9b60269b780b0d49a5f7161509f081a9428ac1c diff --git a/obj/Debug/net9.0/matrix_1_variante.GeneratedMSBuildEditorConfig.editorconfig b/obj/Debug/net9.0/matrix_1_variante.GeneratedMSBuildEditorConfig.editorconfig new file mode 100644 index 0000000..4e1a4f9 --- /dev/null +++ b/obj/Debug/net9.0/matrix_1_variante.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_1_variante +build_property.ProjectDir = /home/BrainTheBest5/git/matrix_1_variante/ +build_property.EnableComHosting = +build_property.EnableGeneratedComInterfaceComImportInterop = +build_property.EffectiveAnalysisLevelStyle = 9.0 +build_property.EnableCodeStyleSeverity = diff --git a/obj/Debug/net9.0/matrix_1_variante.GlobalUsings.g.cs b/obj/Debug/net9.0/matrix_1_variante.GlobalUsings.g.cs new file mode 100644 index 0000000..8578f3d --- /dev/null +++ b/obj/Debug/net9.0/matrix_1_variante.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_1_variante.assets.cache b/obj/Debug/net9.0/matrix_1_variante.assets.cache new file mode 100644 index 0000000..5dae0ab Binary files /dev/null and b/obj/Debug/net9.0/matrix_1_variante.assets.cache differ diff --git a/obj/Debug/net9.0/matrix_1_variante.csproj.CoreCompileInputs.cache b/obj/Debug/net9.0/matrix_1_variante.csproj.CoreCompileInputs.cache new file mode 100644 index 0000000..a128788 --- /dev/null +++ b/obj/Debug/net9.0/matrix_1_variante.csproj.CoreCompileInputs.cache @@ -0,0 +1 @@ +88656dc69ca442cb79240a8d7243281dbb896c2dcf209710202ff0bc71f9557b diff --git a/obj/Debug/net9.0/matrix_1_variante.csproj.FileListAbsolute.txt b/obj/Debug/net9.0/matrix_1_variante.csproj.FileListAbsolute.txt new file mode 100644 index 0000000..a03b9a0 --- /dev/null +++ b/obj/Debug/net9.0/matrix_1_variante.csproj.FileListAbsolute.txt @@ -0,0 +1,14 @@ +/home/Verde/git/matrix_1_variante/bin/Debug/net9.0/matrix_1_variante +/home/Verde/git/matrix_1_variante/bin/Debug/net9.0/matrix_1_variante.deps.json +/home/Verde/git/matrix_1_variante/bin/Debug/net9.0/matrix_1_variante.runtimeconfig.json +/home/Verde/git/matrix_1_variante/bin/Debug/net9.0/matrix_1_variante.dll +/home/Verde/git/matrix_1_variante/bin/Debug/net9.0/matrix_1_variante.pdb +/home/Verde/git/matrix_1_variante/obj/Debug/net9.0/matrix_1_variante.GeneratedMSBuildEditorConfig.editorconfig +/home/Verde/git/matrix_1_variante/obj/Debug/net9.0/matrix_1_variante.AssemblyInfoInputs.cache +/home/Verde/git/matrix_1_variante/obj/Debug/net9.0/matrix_1_variante.AssemblyInfo.cs +/home/Verde/git/matrix_1_variante/obj/Debug/net9.0/matrix_1_variante.csproj.CoreCompileInputs.cache +/home/Verde/git/matrix_1_variante/obj/Debug/net9.0/matrix_1_variante.dll +/home/Verde/git/matrix_1_variante/obj/Debug/net9.0/refint/matrix_1_variante.dll +/home/Verde/git/matrix_1_variante/obj/Debug/net9.0/matrix_1_variante.pdb +/home/Verde/git/matrix_1_variante/obj/Debug/net9.0/matrix_1_variante.genruntimeconfig.cache +/home/Verde/git/matrix_1_variante/obj/Debug/net9.0/ref/matrix_1_variante.dll diff --git a/obj/Debug/net9.0/matrix_1_variante.dll b/obj/Debug/net9.0/matrix_1_variante.dll new file mode 100644 index 0000000..4157cd7 Binary files /dev/null and b/obj/Debug/net9.0/matrix_1_variante.dll differ diff --git a/obj/Debug/net9.0/matrix_1_variante.genruntimeconfig.cache b/obj/Debug/net9.0/matrix_1_variante.genruntimeconfig.cache new file mode 100644 index 0000000..3007b4d --- /dev/null +++ b/obj/Debug/net9.0/matrix_1_variante.genruntimeconfig.cache @@ -0,0 +1 @@ +22436567e401ea4a15fa5932ef52fa0af7d9ab55bd2885c5379d783a8e74d65d diff --git a/obj/Debug/net9.0/matrix_1_variante.pdb b/obj/Debug/net9.0/matrix_1_variante.pdb new file mode 100644 index 0000000..f474ddb Binary files /dev/null and b/obj/Debug/net9.0/matrix_1_variante.pdb differ diff --git a/obj/Debug/net9.0/ref/matrix_1_variante.dll b/obj/Debug/net9.0/ref/matrix_1_variante.dll new file mode 100644 index 0000000..32a3b89 Binary files /dev/null and b/obj/Debug/net9.0/ref/matrix_1_variante.dll differ diff --git a/obj/Debug/net9.0/refint/matrix_1_variante.dll b/obj/Debug/net9.0/refint/matrix_1_variante.dll new file mode 100644 index 0000000..32a3b89 Binary files /dev/null and b/obj/Debug/net9.0/refint/matrix_1_variante.dll differ