Exercice 1
#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)
{
. . .
}Exercice 2
int RANGER(int *X, int *Y)
{
int AIDE;
if (*X>*Y)
{
AIDE = *X;
*X = *Y;
*Y = AIDE;
return 1;
}
else
return 0;
}Pages: 1 2