Trouver la valeur maximale d’un tableau

Author:

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

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

  public static class ValeursMax
  {

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

      double resultat = double.MinValue;

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

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

  }

Leave a Reply

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