Creazione matrice

This commit is contained in:
La Programmatrice Verde 2025-07-21 14:16:04 +02:00
parent cafc48ce64
commit 0314f06fda
16 changed files with 129 additions and 5 deletions

View File

@ -1,7 +1,6 @@
namespace vacanzeEstive_sezione2; namespace vacanzeEstive_sezione2;
class Program class Program {
{
static void Main(string[] args) { static void Main(string[] args) {
Console.Clear(); Console.Clear();
int scelta = -1; int scelta = -1;
@ -18,6 +17,7 @@ class Program
case 0: case 0:
break; break;
case 1: case 1:
CreaMatrice();
Pausa(); Pausa();
break; break;
default: default:
@ -40,4 +40,77 @@ class Program
Console.WriteLine("Premere un tasto per continuare. . ."); Console.WriteLine("Premere un tasto per continuare. . .");
Console.ReadKey(); Console.ReadKey();
} }
static int[,] CreaMatrice() {
uint righe = 0, colonne = 0;
bool error;
do {
error = false;
Console.Write("Inserire il numero di righe della matrice: ");
try {
righe = Convert.ToUInt32(Console.ReadLine());
if (righe < 1) {
error = true;
Console.WriteLine("Errore: non sono ammesse dimensioni inferiori a 2.");
Pausa();
}
}
catch (FormatException) {
error = true;
Console.WriteLine("Errore: dimensione non valida.");
Pausa();
}
catch (OverflowException) {
error = true;
Console.WriteLine("Errore: non sono ammesse dimensioni negative.");
Pausa();
}
} while (error);
do {
error = false;
Console.Write("Inserire il numero di colonne della matrice: ");
try {
colonne = Convert.ToUInt32(Console.ReadLine());
if (colonne < 1) {
error = true;
Console.WriteLine("Errore: non sono ammesse dimensioni inferiori a 2.");
Pausa();
}
}
catch (FormatException) {
error = true;
Console.WriteLine("Errore: dimensione non valida.");
Pausa();
}
catch (OverflowException) {
error = true;
Console.WriteLine("Errore: non sono ammesse dimensioni negative.");
Pausa();
}
} while (error);
return RiempiMatrice(new int[righe, colonne]);
}
static int[,] RiempiMatrice(int[,] p_matrix) {
int elemento;
for (int r = 0; r < p_matrix.GetLength(0); r++) {
for (int c = 0; c < p_matrix.GetLength(1); c++) {
Console.Write($"Inserire l'elemento in posizione {r},{c}: ");
try {
elemento = Convert.ToInt32(Console.ReadLine());
}
catch (FormatException) {
Console.WriteLine("Errore: elemento non valido.");
Pausa();
}
}
}
return p_matrix;
}
} }

Binary file not shown.

View File

@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v9.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v9.0": {
"vacanzeEstive_sezione2/1.0.0": {
"runtime": {
"vacanzeEstive_sezione2.dll": {}
}
}
}
},
"libraries": {
"vacanzeEstive_sezione2/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
}
}
}

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -13,10 +13,10 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("vacanzeEstive_sezione2")] [assembly: System.Reflection.AssemblyCompanyAttribute("vacanzeEstive_sezione2")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0f979af2d96a8dff513ac6474c5c8e3c7bcd1fb5")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+cafc48ce6407bf16c0d16b4fde5ee8673539a6ca")]
[assembly: System.Reflection.AssemblyProductAttribute("vacanzeEstive_sezione2")] [assembly: System.Reflection.AssemblyProductAttribute("vacanzeEstive_sezione2")]
[assembly: System.Reflection.AssemblyTitleAttribute("vacanzeEstive_sezione2")] [assembly: System.Reflection.AssemblyTitleAttribute("vacanzeEstive_sezione2")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class. // Generato dalla classe WriteCodeFragment di MSBuild.

View File

@ -1 +1 @@
220dabe602bbe8b64032d5752b075c9dcd5ebdb82403a4a7ecfe7e3d7b268563 f51dd8e398f51ce3006057d64eb8817f1c96774015caa399a7ccd91231d29a3e

View File

@ -0,0 +1 @@
4ed8f9bada649f86edd5892680ac069d0771e049f4facf85f62be400d2283e5f

View File

@ -0,0 +1,14 @@
/home/Verde/git/vacanzeEstive_sezione2/bin/Debug/net9.0/vacanzeEstive_sezione2
/home/Verde/git/vacanzeEstive_sezione2/bin/Debug/net9.0/vacanzeEstive_sezione2.deps.json
/home/Verde/git/vacanzeEstive_sezione2/bin/Debug/net9.0/vacanzeEstive_sezione2.runtimeconfig.json
/home/Verde/git/vacanzeEstive_sezione2/bin/Debug/net9.0/vacanzeEstive_sezione2.dll
/home/Verde/git/vacanzeEstive_sezione2/bin/Debug/net9.0/vacanzeEstive_sezione2.pdb
/home/Verde/git/vacanzeEstive_sezione2/obj/Debug/net9.0/vacanzeEstive_sezione2.GeneratedMSBuildEditorConfig.editorconfig
/home/Verde/git/vacanzeEstive_sezione2/obj/Debug/net9.0/vacanzeEstive_sezione2.AssemblyInfoInputs.cache
/home/Verde/git/vacanzeEstive_sezione2/obj/Debug/net9.0/vacanzeEstive_sezione2.AssemblyInfo.cs
/home/Verde/git/vacanzeEstive_sezione2/obj/Debug/net9.0/vacanzeEstive_sezione2.csproj.CoreCompileInputs.cache
/home/Verde/git/vacanzeEstive_sezione2/obj/Debug/net9.0/vacanzeEstive_sezione2.dll
/home/Verde/git/vacanzeEstive_sezione2/obj/Debug/net9.0/refint/vacanzeEstive_sezione2.dll
/home/Verde/git/vacanzeEstive_sezione2/obj/Debug/net9.0/vacanzeEstive_sezione2.pdb
/home/Verde/git/vacanzeEstive_sezione2/obj/Debug/net9.0/vacanzeEstive_sezione2.genruntimeconfig.cache
/home/Verde/git/vacanzeEstive_sezione2/obj/Debug/net9.0/ref/vacanzeEstive_sezione2.dll

Binary file not shown.

View File

@ -0,0 +1 @@
034bd2f866258b263178a67151a5d92c9c02f7ff937c4d945fbe2ecc12c6ae25

Binary file not shown.