Advertisement
Fhernd

MultiplesValoresRetorno.cs

Mar 27th, 2016
11,380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace Articulo.Pregunta.P2020
  5. {
  6.     public class MultiplesValoresRetorno
  7.     {
  8.         public static void Main()
  9.         {
  10.             // Declaración arreglo con valores enteros:
  11.             int[] arregloEnteros = new int[] {61, 13, 5, 23, 29};
  12.            
  13.             // Cómputo de máximo y mínimo:
  14.             MaximoMinimo maxMinResultado = ObtenerMaximoMinimo(arregloEnteros);
  15.            
  16.             // Visualización de resultados:
  17.             Console.WriteLine ("\nMáximo: {0}; mínimo: {1}\n", maxMinResultado.Maximo, maxMinResultado.Minimo);
  18.         }
  19.        
  20.         // Calcula el máximo y mínimo de un arreglo de enteros:
  21.         public static MaximoMinimo ObtenerMaximoMinimo(int[] valores)
  22.         {
  23.             MaximoMinimo maxMin = new MaximoMinimo();
  24.             maxMin.Maximo = valores.Max();
  25.             maxMin.Minimo = valores.Min();
  26.            
  27.             return maxMin;
  28.         }
  29.     }
  30.    
  31.     // Estructura para representar el máximo y el máximo de números enteros:
  32.     public struct MaximoMinimo
  33.     {
  34.         private int maximo;
  35.         private int minimo;
  36.        
  37.         public int Maximo
  38.         {
  39.             get
  40.             {
  41.                 return maximo;
  42.             }
  43.             set
  44.             {
  45.                 maximo = value;
  46.             }
  47.         }
  48.        
  49.         public int Minimo
  50.         {
  51.             get
  52.             {
  53.                 return minimo;
  54.             }
  55.             set
  56.             {
  57.                 minimo = value;
  58.             }
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement