Trouver la valeur minimale d’une liste

Author:

ArrayList, Array, HashTable, BitArray
{filelink=18439}


using System;

  public static class ValeursMin
  {

    public static double ValeurMin(params double[] valeurs)
    {
      if (valeurs == null || valeurs.Length == 0)
        throw new ArgumentNullException("valeurs");

      double resultat = double.MaxValue;

      for (int i = 0; i < valeurs.Length; i++)
      {
        resultat = Math.Min(resultat, valeurs[i]);
      }

      return resultat;
    }
    public static void Main(string[] argv)
     {
         Console.WriteLine("La valeur minimale du tableau {12,20,3,200,250} est: " + ValeurMin(new Double[] { 12, 20, 3, 200, 250 }));
     }

 }

Leave a Reply

Your email address will not be published. Required fields are marked *