Funziona tutto

This commit is contained in:
La Programmatrice Verde 2025-03-07 10:03:45 +01:00
parent 536e6e5457
commit 5e2c571db6
20 changed files with 174 additions and 5 deletions

View File

@ -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}");
}
}
}
}
}

Binary file not shown.

View File

@ -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": ""
}
}
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net9.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "9.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]

BIN
obj/Debug/net9.0/apphost Executable file

Binary file not shown.

View File

@ -0,0 +1,22 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
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.

View File

@ -0,0 +1 @@
01871b8f3d99b94fd01d8d8ce9b60269b780b0d49a5f7161509f081a9428ac1c

View File

@ -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 =

View File

@ -0,0 +1,8 @@
// <auto-generated/>
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;

Binary file not shown.

View File

@ -0,0 +1 @@
88656dc69ca442cb79240a8d7243281dbb896c2dcf209710202ff0bc71f9557b

View File

@ -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

Binary file not shown.

View File

@ -0,0 +1 @@
22436567e401ea4a15fa5932ef52fa0af7d9ab55bd2885c5379d783a8e74d65d

Binary file not shown.

Binary file not shown.

Binary file not shown.