Home
Browsez les 647 exemples
Téléchargez les 647 exemples
Téléchargez des chapitres
Achetez sur amazon.fr

Niveau: Débutant/Intermédiaire
ISBN-2-84177-339-6
50 Euros

Exemple 15-5 extrait du chapitre Collections


Exemple 15-4<     > Exemple 15-6


Cet exemple peut être compilé avec la ligne de commande:
csc.exe /target:exe Exemple_15_5.cs
Erreurs: 0 Avertissements: 0
Remarque:


Exemple_15_5.cs
using System;
using System.Diagnostics;
class Program {
   const int N_ITERATION = 10000;
   const int N_ELEM = 100;
   static void Main() {
      int tmp = 0;

      int[][] arrayJagged = new int[N_ELEM][];
      for (int = 0; i < N_ELEM; i++)
         arrayJagged[i] = new int[N_ELEM];
      Stopwatch sw = Stopwatch.StartNew();
      for (int = 0; k < N_ITERATION; k++)
         for (int = 0; i < N_ELEM; i++)
            for (int = 0; j < N_ELEM; j++){
               tmp = arrayJagged[i][j];
               arrayJagged[i][j] = i * j;
            }
      Console.WriteLine("Tableau irrégulier: " + sw.Elapsed );

      int[,] arrayMultiDim = new int[N_ELEM, N_ELEM];
      sw = Stopwatch.StartNew();
      for (int = 0; k < N_ITERATION; k++)
         for (int = 0; i < N_ELEM; i++)
            for (int = 0; j < N_ELEM; j++){
               tmp = arrayMultiDim[i, j];
               arrayMultiDim[i, j] = i * j;
            }
      Console.WriteLine("Tableau multidimensionnel:" + sw.Elapsed );
   }
}	
Copyright Patrick Smacchia 2006 2007