Funzione per l'input

This commit is contained in:
La Programmatrice Verde 2025-02-07 08:47:29 +01:00
parent d38856b73c
commit 7e5fac9c45
7 changed files with 87 additions and 4 deletions

View File

@ -1,9 +1,42 @@
namespace interrogazione_1; namespace interrogazione_1;
class Program class Program {
{ static void Main(string[] args) {
static void Main(string[] args)
{
Console.WriteLine("Hello, World!"); Console.WriteLine("Hello, World!");
} }
static int[] Input() {
//dichiarazione e inizializzazione variabili
int dimensione, input = 0, i = 0;
//input della dimensione
do {
Console.Write("Quanti valori vuoi inserire? ");
dimensione = Convert.ToInt32(Console.ReadLine());
if (dimensione <= 0) {
Console.WriteLine("Dimensione non valida.");
Pausa();
}
}
while (dimensione <= 0);
//creazione array
int[] ritorno = new int[dimensione];
//Riempimento array
while (i < dimensione || input == Int32.MaxValue) {
Console.Write($"Inserire il valore n. {i}: ");
input = Convert.ToInt32(Console.ReadLine());
if (input == Int32.MaxValue) {
Console.Write("Valore non valido");
Pausa();
}
else {
ritorno[i] = input;
i++;
}
}
return ritorno;
}
} }

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")]

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("interrogazione_1")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d38856b73cb595d7894423740188b39c6fb3510a")]
[assembly: System.Reflection.AssemblyProductAttribute("interrogazione_1")]
[assembly: System.Reflection.AssemblyTitleAttribute("interrogazione_1")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// Generated by the MSBuild WriteCodeFragment class.

View File

@ -0,0 +1 @@
5eb9505a53b7be7239957238711ee9d545ae27922a39c4eb40cac9637ffa15ee

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 = interrogazione_1
build_property.ProjectDir = /home/Verde/git/interrogazione_1/
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.