1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
   |  
Program DH2EXO2;
Uses CRT;
Type
    mot=array[0..21] of integer;
    liste_mots=^doublet;
    doublet=record
                  info:mot;
                  suiv:liste_mots
    end;
    tableau_de_liste_mots=array[0..100] of liste_mots;
Var
   u,x,y,w:mot;
   l1,l2,l3,l4,liste,sommet:liste_mots;
 
 
{*********************************************************************}
{***   Procedure d'affichage d'un mot   ***}
Procedure disp_mot(u:mot);
var
   i:integer;
begin
     for i:=1 to u[0] do
         write(u[i],' ');
     writeln;
end;
{*********************************************************************}
 
{*********************************************************************}
{***   Procedure d'affichage d'une liste de mots   ***}
procedure disp_list(l:liste_mots);
var
   i:integer;
begin
     i:=1;
     while (l <> nil) do
           begin
                write('Mot nø',i,' : ');
                disp_mot(l^.info);
                i:=i+1;
                l:=l^.suiv;
           end;
end;
{*********************************************************************}
 
 
{*********************************************************************}
{***   Fonction concat   ***}
Function concat(l1,l2:liste_mots):liste_mots;
var
   la,lb,l:liste_mots;
begin
     la:=l1;
     lb:=l2;
     l:=la;
     while (l^.suiv <> nil) do
           l:=l^.suiv;
     l^.suiv:=lb;
     concat:=l;
end;
{*********************************************************************}
 
 
begin
     clrscr;
     {***   Test est_bien_forme   ***}
     u[0]:=5;
     u[1]:=1;
     u[2]:=1;
     u[3]:=-1;
     u[4]:=-1;
     u[5]:=1;
     x[0]:=5;
     x[1]:=1;
     x[2]:=1;
     x[3]:=-1;
     x[4]:=-1;
     x[5]:=-1;
     y[0]:=5;
     y[1]:=1;
     y[2]:=-1;
     y[3]:=1;
     y[4]:=-1;
     y[5]:=-1;
     construire(x,y,w);
     {***   La procédure construire construit le mot w à partir de x et y tel que : w=(x[0]+y[0],1,x[1],...,x[x[0]],y[1],...,y[y[0]])  ***}
     {***   A noter que la composante d'indice 0 d'un mot contient sa longueur   ***}
     {***   on construit une liste avec les mots x,y et w   ***}
     new(liste);
     liste^.info:=w;
     liste^.suiv:=nil;
     sommet:=liste;
     new(liste);
     liste^.info:=y;
     liste^.suiv:=sommet;
     sommet:=liste;
     new(liste);
     liste^.info:=x;
     liste^.suiv:=sommet;
     {***   liste est construite   ***}
     disp_list(liste);
     {***   Test concat   ***}
     {***   on construit l1 et l2   ***}
     writeln;
     writeln('***************** Test concat ***');
     l1:=liste;
     write('l1 : ');
     disp_list(l1);
     new(l2);
     l2^.info:=w;
     l2^.suiv:=nil;
     sommet:=l2;
     new(l2);
     l2^.info:=y;
     l2^.suiv:=sommet;
     writeln;
     write('l2 : ');
     disp_list(l2);
     {*** l1 et l2 sont construites   ***}
     writeln;
     writeln('Après appel de concat...');
     l3:=concat(l1,l2);
     writeln;
     writeln('l1 :');
     disp_list(l1);
     writeln;
     writeln('l2 :');
     disp_list(l2);
     writeln;
     writeln('l3 :');
     disp_list(l3);
     {writeln;
     write('l3 : ');
     disp_list(l3);
     writeln('Longueur de la liste concatenee : ',longueur(l3));
     {***   Fin test concat   ***}
     readkey;
end. |