#include <stdio.h> main() { /* Prototypes des fonctions appelées */ void FUSION(int *A, int *B, int *FUS, int N, int M); void TRI_BULLE(int *T, int N); void LIRE_TAB (int *TAB, int *N, int NMAX); void ECRIRE_TAB (int *TAB, int N); /* Variables locales */ /* Les tableaux et leurs dimensions */ int A[100], B[100], FUS[200]; int N, M; /* Traitements */ printf("*** Tableau A ***\n"); LIRE_TAB (A, &N, 100); printf("*** Tableau B ***\n"); LIRE_TAB (B, &M, 100); TRI_BULLE(A, N); printf("Tableau A trié : \n"); ECRIRE_TAB (A, N); TRI_BULLE(B, M); printf("Tableau B trié : \n"); ECRIRE_TAB (B, M); FUSION(A,B,FUS,N,M); printf("Tableau FUS : \n"); ECRIRE_TAB (FUS, N+M); return 0; } void FUSION(int *A, int *B, int *FUS, int N, int M) { /* Variables locales */ /* Indices courants dans A, B et FUS */ int IA,IB,IFUS; /* Fusion de A et B dans FUS */ IA=0, IB=0; IFUS=0; while ((IA<N) && (IB<M)) if (*(A+IA)<*(B+IB)) { *(FUS+IFUS)=*(A+IA); IFUS++; IA++; } else { FUS[IFUS]=B[IB]; IFUS++; IB++; } /* Si A ou B sont arrivés à la fin, alors */ /* copier le reste de l'autre tableau. */ while (IA<N) { *(FUS+IFUS)=*(A+IA); IFUS++; IA++; } while (IB<M) { *(FUS+IFUS)=*(B+IB); IFUS++; IB++; } } void TRI_BULLE(int *T, int N) { /* Prototypes des fonctions appelées */ int RANGER(int *X, int *Y); . . . } int RANGER(int *X, int *Y) { . . . } void LIRE_TAB (int *TAB, int *N, int NMAX) { . . . } void ECRIRE_TAB (int *TAB, int N) { . . . }