Previous Next Up Index Contents

Exercice 10.21 Tri par insertion

#include <stdio.h>

main()
{
 /* Prototypes des fonctions appelées */
 void TRI_INSERTION(int *T, int N);
 void LIRE_TAB (int *TAB, int *N, int NMAX);
 void ECRIRE_TAB (int *TAB, int N);
 /* Variables locales */
 int T[100]; /* Tableau d'entiers */
 int DIM;    /* Dimension du tableau */
 /* Traitements */
 LIRE_TAB (T, &DIM, 100);
 printf("Tableau donné : \n");
 ECRIRE_TAB (T, DIM);
 TRI_INSERTION(T, DIM);
  printf("Tableau trié : \n");
 ECRIRE_TAB (T, DIM);
 return 0;
}


void TRI_INSERTION(int *T, int N)
{
  void INSERER(int X, int *T, int *N);
 /* Variables locales */
 int I;  /* indice courant */
 /* Tri de T par insertion */
 I=1;
 while (I<N)
      INSERER(*(T+I), T, &I);
}
 
void INSERER(int X, int *T, int *N)
{
 . . .
}

void LIRE_TAB (int *TAB, int *N, int NMAX)
{
 . . .
}

void ECRIRE_TAB (int *TAB, int N)
{
 . . .
}


Previous Next Up Index Contents

Feedback - Copyright © 1993,1996,1997 F.Faber