(* ********************************************************** *) (* SOURCE : P.LOG PROGRAMME : Visualisation de coroutines sur l'exemple du programme merge.log AUTEURS : BEAU Anne-Valerie DELBURG Myriam *) (* ********************************************************** *) (* Les units utilises : ecrit lit affiche_abr affiche_prg affiche_cor node efface pause mousepos rectangle inchar menu presentation *) BLOCK (* COROUTINE MERGE OF BINARY TREES*) (*************************************************************) unit ecrit : iiuwgraph procedure( Number : integer ); var n1, n2, n3 : integer; begin if Number < 10 then call HASCII(0); call HASCII(Number + 48); call Hascii(0); else if Number < 100 then n1 := Number div 10; n2 := Number - n1 * 10; call HASCII(0); call Hascii(n1 + 48); call Hascii(0); call Hascii(n2 + 48); else n1 := Number div 100; n2 := (Number - n1 * 100) div 10; n3 := Number - n1 * 100 - n2 * 10; call HASCII(0); call Hascii(n1 + 48); call Hascii(0); call Hascii(n2 + 48); call HASCII(0); call Hascii(n3 + 48); fi; fi; call outstring(" "); end ecrit; (*************************************************************) unit lit : iiuwgraph function : integer; var X,Y,i, OrdN : integer, Number : arrayof integer; begin array Number dim(1:4); i:= 0 ; X := InXPos; Y := InYPos; do OrdN:=inchar; if i = 8 or (OrdN < 48 and OrdN > 57) then exit fi; case OrdN when 48 : i:=i+1; Number(i):=0; when 49 : i:=i+1; Number(i):=1; when 50 : i:=i+1; Number(i):=2; when 51 : i:=i+1; Number(i):=3; when 52 : i:=i+1; Number(i):=4; when 53 : i:=i+1; Number(i):=5; when 54 : i:=i+1; Number(i):=6; when 55 : i:=i+1; Number(i):=7; when 56 : i:=i+1; Number(i):=8; when 57 : i:=i+1; Number(i):=9; when 8 : if i>0 then Number(i) := 0; i := i - 1; call hascii(0); fi; when 13 : if i > 0 then exit fi ; esac; if i = 1 then call Move(X,Y); call hascii(0); call hascii(48+Number(1)); fi; if i = 2 then call Move(X + 8,Y); call hascii(0); call hascii(48 + Number(2)); fi; od; if (Number(1) =0 ) or (Number(1) = 0 and Number(2) = 0) or (Number(1) = 0 and Number(2) = 0 and Number(3) = 0) then call Move(X,Y); call hascii(0); call hascii(48); call hascii(0); fi; if i = 1 then result := Number(1); else if i = 2 then result := 10 * Number(1) + Number (2); else result := 100 * Number(1) + 10 * Number(2) + Number(3); fi; fi; kill(Number); end lit; (*************************************************************) unit inchar : iiuwgraph function : integer; var c : integer; begin do c := inkey; if c =/= 0 then exit fi; od; result := c; end inchar; (*************************************************************) unit mousepos : iiuwgraph procedure(A,B : integer; output chx : integer); begin if ((A>50) and (A<170)) then if ((B>325) and (B<345)) then chx := 1; fi; else if ((A>260) and (A<380)) then if ((B>290) and (B<310)) then chx := 2; fi; fi; fi; end mousepos; (*************************************************************) unit rectangle : iiuwgraph procedure(X1,Y1,X2,Y2 : integer); begin call move(X1,Y1); call draw(X2,Y1); call move(X2,Y1); call draw(X2,Y2); call move(X2,Y2); call draw(X1,Y2); call move(X1,Y2); call draw(X1,Y1); end rectangle; (*************************************************************) unit affiche_prg : iiuwgraph procedure; begin call color(13); call move(5,5); call draw(5,325); call draw(400,325); call draw(400,5); call draw(5,5); call move(5,15); call draw(400,15); call move(100,7); call outstring("DL"); call move(260,7); call outstring("SL"); call move(5,97); call draw(400,97); call move(370,330); call outstring("main"); call color(3); call move(10,17); call outstring("program merge;"); call move(20,26); call outstring("unit node:class;...;"); call move(30,35); call outstring("unit ins:procedure(value:integer);...;end ins;"); call move(20,44); call outstring("end node;"); call move(20,53); call outstring("unit travers:coroutine(x:node);...;"); call move(30,62); call outstring("unit t:procedure(y:node);...;end t;"); call move(20,71); call outstring("end travers;"); call move(20,80); call outstring("var n ,i ,j ,min ,m :integer,"); call color(12); call move(63,80); call outstring(" "); call move(63,80); call ecrit(n); call move(108,80); call outstring(" "); call move(108,80); call ecrit(i); call move(158,80); call outstring(" "); call move(158,80); call ecrit(j); call move(228,80); call outstring(" "); call move(228,80); call ecrit(min); call move(285,80); call outstring(" "); call move(285,80); call ecrit(m); call color(3); call move(30,89); call outstring("d:arrayof node, tr:array of travers;"); call move(10,98); call outstring("begin"); call move(20,107); call outstring("writeln('Donnez le nombre d'arbres :');read(n);"); call move(20,116); call outstring("array d dim(1:n);"); call move(20,125); call outstring("for i:=1 to n do"); call move(30,134); call outstring("writeln('Donnez la sequence de l'arbre no :');"); call move(30,143); call outstring("read(j); if j>m then m:=j fi;"); call move(30,152); call outstring("d(i):=new node; d(i).val:=j;"); call move(30,161); call outstring("do"); call move(40,170); call outstring("read(j); if j=0 then exit fi;"); call move(40,179); call outstring("if j>m then m:=j fi; call d(i).ins(j);"); call move(30,188); call outstring("od;"); call move(20,197); call outstring("od;"); call move(20,206); call outstring("m:=m+1; array tr dim(1:n); min:=0;"); call move(20,215); call outstring("for i:=1 to n do"); call move(30,224); call outstring("tr(i):=new travers(d(i)); attach(tr(i));"); call move(20,233); call outstring("od;"); call move(20,242); call outstring("writeln('La fusion de la sequence est :');"); call move(20,251); call outstring("do"); call move(30,260); call outstring("if min=m then exit fi; min:=tr(1).val; j:=1;"); call move(30,269); call outstring("for i:=2 to n do"); call move(40,278); call outstring("if min>tr(i).val then min:=tr(i).val;j:=i;fi;"); call move(30,287); call outstring("od;"); call move(30,296); call outstring("if min2 then call color(3); call move(x1+5,y1+5); call outstring("..."); call color(9); call rectangle(x1,y1,x2,y2); call move(x1,y1+5); call draw(400,y1+5); y1:=y1+20; y2:=y2+20; call color(3); call move(x1+5,y1+5); call ecrit(n); call color(9); call rectangle(x1,y1,x2,y2); call move(x1,y1+5); call draw(400,y1+5); y1:=y1+20; y2:=y2+20; fi; fi; end affiche_abr; (*************************************************************) unit affiche_cor : iiuwgraph procedure(x1,y1,x2,y2:integer); begin call color(13); call rectangle(x1,y1,x2,y2); call move(x1,y1+10); call draw(x2,y1+10); call move(x1+50,y1+2); call outstring("DL"); call move(x1+150,y1+2); call outstring("SL"); call move(x1,y1+145); call draw(x2,y1+145); call move(x2-55,y2+5); call outstring("travers"); call color(3); call move(x1+5,y1+15); call outstring("unit travers:coroutine"); call move(x1+30,y1+25); call outstring("(x:node);"); call move(x1+10,y1+35); call outstring("var val : interger;"); call move(x1+170,y1+35); call color(12); call outstring(" "); call move(x1+170,y1+35); call ecrit(valeur); call color(3); call move(x1+10,y1+45); call outstring("unit t:procedure(y:node);"); call move(x1+10,y1+55); call outstring("begin"); call move(x1+15,y1+65); call outstring("if y=/=none"); call move(x1+15,y1+75); call outstring("then"); call move(x1+20,y1+85); call outstring("call t(y.left);"); call move(x1+20,y1+95); call outstring("val:=y.val;"); call move(x1+20,y1+105); call outstring("detach;"); call move(x1+20,y1+115); call outstring("call t(y.right);"); call move(x1+15,y1+125); call outstring("fi;"); call move(x1+10,y1+135); call outstring("end t;"); call color(5); call color(3); call move(x1+5,y1+150); call outstring("begin"); call move(x1+10,y1+160); call outstring("return;"); call move(x1+10,y1+170); call outstring("call t(x);"); call move(x1+10,y1+180); call outstring("val:=m;"); call move(x1+5,y1+190); call outstring("end travers;"); end affiche_cor; (*************************************************************) unit presentation : iiuwgraph procedure; begin call border(5); call color(13); call rectangle(115,90,515,120); call color(3); call move(125,100); call outstring("VISUALISATION DES COROUTINES DU PROGRAMME MERGE"); call move(65,160); call outstring("Ce programme utilise les coroutines et fusionne un nombre donn‚"); call move(65,185); call outstring("d'arbres de recherche."); call pause; call cls; end presentation; (*************************************************************) unit menu : iiuwgraph procedure(output chx:integer); var b,h,v : integer; begin pref mouse block begin if (driver) then call color(1); call rectangle(20,328,140,348); call move(50,335); call color(15); call outstring("Quitter"); call move(170,340); call outstring("Ou cliquer ailleurs pour continuer"); call move(400,330); call showcursor; do call getpress(0,h,v,b,gauche,droit,centre); if gauche then call mousepos(h,v,chx); call hidecursor; gauche := false; exit; fi; od; else call move(150,340); call outstring("SERVEZ-VOUS DE LA SOURIS"); call pause; chx := 5; exit; fi; end; end menu; (*************************************************************) unit menu1 : iiuwgraph procedure(output chx:integer); var b,h,v : integer; begin pref mouse block begin if (driver) then call color(13); call style(2); call rectangle(200,160,430,180); call color(3); call move(210,165); call outstring("L'application est termin‚e"); call color(1); call rectangle(260,290,380,310); call move(295,297); call color(15); call style(3); call outstring("Quitter"); call move(400,330); call showcursor; do call getpress(0,h,v,b,gauche,droit,centre); if gauche then call mousepos(h,v,chx); call hidecursor; gauche := false; exit; fi; od; else call move(150,340); call outstring("SERVEZ-VOUS DE LA SOURIS"); call pause; chx := 5; exit; fi; end; end menu1; (*************************************************************) unit efface : iiuwgraph procedure; begin call move(150,340); call outstring(" "); end efface; (*************************************************************) unit efface_zone : iiuwgraph procedure; var cpt : integer; begin for cpt:=1 to 9 do call move(231,cpt); call outstring(" "); od; for cpt:=5 to 25 do call move(317,cpt); call outstring(" "); od; for cpt:=30 to 160 do call move(231,cpt); call outstring(" "); od; end efface_zone; (*************************************************************) unit pause : iiuwgraph procedure; var touche : char; begin pref mouse block; var h,b,v,p : integer, touche : char; begin droit := false; driver := init(b); if (driver) then call color(15); call move(150,340); call outstring("Appuyez sur le bouton droit de la souris"); call move(400,340); while (not droit) do call getpress(1,h,v,p,gauche,droit,centre); od; call move(150,340); call outstring(" "); call color(5); else call move(150,340); call outstring(" "); call move(150,340); call outstring("Appuyez sur une touche"); read (touche); fi; end; end pause; unit aff : iiuwgraph procedure(num : integer); begin call color(13); call move(260,18); call outstring("tr("); call ecrit(num); call move(310,18); call outstring(")"); call move(255,20); call draw(235,20); call move(230,17); call outstring("<"); end aff; (*************************************************************) UNIT NODE : CLASS; (* NODE OF BINARY TREE *) VAR LEFT,RIGHT : NODE, VAL,tuer : INTEGER; (*SEARCHING KEY *) UNIT INS : PROCEDURE (VALUE : INTEGER); BEGIN IF VAL> VALUE THEN IF LEFT = NONE THEN LEFT := NEW NODE; LEFT.VAL := VALUE; ELSE CALL LEFT.INS(VALUE); FI; ELSE (* ELEMENTS NOT LESS THAN VAL ARE LOCATED IN THE RIGHT SUBTREE *) IF RIGHT = NONE THEN RIGHT := NEW NODE; RIGHT.VAL := VALUE; ELSE CALL RIGHT.INS(VALUE); FI; FI; END INS; END NODE; unit reaffiche_boi : iiuwgraph procedure(courant,boite : node, hmin, hmax, vmax, hauteur : integer); var w : integer; begin if sortir =/= 1 then IF boite =/= NONE THEN if hauteur > 2 then call efface_zone; hauteur := 0; hmin := 240; hmax := 630; vmax := 10; fi; w := ((hmin - hmax) / 2) + hmax; call move(w-5,vmax+10); call color(12); call ecrit(boite.val); call color(13); call rectangle(w-10,vmax-4,w+38,vmax+20); call move(w-10,vmax+6); call draw(w+38,vmax+6); call move(w-3,vmax-2); call outstring("DL"); call move(w+20,vmax-2); call outstring("SL"); call move(w+30,vmax+25); call outstring("t"); if hauteur < 2 then call trait(w,vmax); fi; if boite = courant then sortir := 1; else if boite.tuer = 0 then CALL reaffiche_boi(courant,boite.left,hmin,w,vmax+60,hauteur+1); fi; CALL reaffiche_boi(courant,boite.RIGHT,w,hmax,vmax+60,hauteur+1); fi; fi; fi; end reaffiche_boi; unit trait : iiuwgraph procedure(mil,bas : integer); begin call color(9); call move(mil-10,bas+14); call draw(mil-60,bas+14); call draw(mil-60,bas+50); call move(mil-67,bas+45); call outstring("\/"); call move(mil+38,bas+14); call draw(mil+88,bas+14); call draw(mil+88,bas+50); call move(mil+81,bas+45); call outstring("\/"); end trait; unit aff_cor : iiuwgraph procedure(x1,y1,x2,y2 : integer); begin call color(9); call move(x1+220,y1+48); call draw(x1+400,y1+5); call move(x1+405,y1); call outstring(">"); call color(2); call move(x1+400,y1-3); call draw(x1+220,y1+3); call move(x1+220,y1); call outstring("<"); call color(11); call move(x1+450,y1-6); call draw(x1+220,y1-6); call move(x1+220,y1-9); call outstring("<"); x1 := 10; x2 := 230; y1 := 10; y2 := 210; call affiche_cor(x1,y1,x2,y2); end aff_cor; (*************************************************************) UNIT TRAVERS : iiuwgraph COROUTINE (X :NODE); (* CONSECUTIVE ELEMENTS OF TREE NODE ARE LOCATED IN THE GROWING ORDER TO *) (* THE "MAIL BOX" VAL AND SENT TO THE ATTACHING UNIT *) VAR VAL : INTEGER; (* ----------------------------------------------------------- *) UNIT T : PROCEDURE (Y : NODE, xmin, xmax, ymax, haut : integer); (* RECURSIVE PROCEDURE FOR INFIX TRAVERSION RESULTING TREE ELEMENTS *) (* IN NOT DECREASING ORDER *) var w : integer; BEGIN x1 := 10; x2 := 230; y1 := 10; y2 := 210; call color(10); call move(x1+10,y1+55); call outstring("begin"); call pause; call affiche_cor(x1,y1,x2,y2); call color(10); call move(x1+15,y1+65); call outstring("if y=/=none"); call pause; call affiche_cor(x1,y1,x2,y2); IF Y =/= NONE THEN call color(10); call move(x1+15,y1+75); call outstring("then"); call pause; if haut > 2 then call efface_zone; haut := 0; xmin := 240; xmax := 630; ymax := 10; fi; w := ((xmin - xmax) / 2) + xmax; call move(w-5,ymax+10); call color(12); call ecrit(y.val); call color(13); call rectangle(w-10,ymax-4,w+38,ymax+20); call move(w-10,ymax+6); call draw(w+38,ymax+6); call move(w-3,ymax-2); call outstring("DL"); call move(w+20,ymax-2); call outstring("SL"); call move(w+30,ymax+25); call outstring("t"); if haut < 2 then call trait(w,ymax); fi; call aff_cor(x1,y1,x2,y2); call color(10); call move(x1+20,y1+85); call outstring("call t(y.left);"); call pause; call aff_cor(x1,y1,x2,y2); CALL T(Y.LEFT,xmin,w,ymax+60,haut+1); sortir := 0; call efface_zone; call reaffiche_boi(y,x,240,630,10,0); call color(10); call move(x1+20,y1+95); call outstring("val:=y.val;"); call pause; call aff_cor(x1,y1,x2,y2); VAL := Y.VAL; valeur := y.val; call color(10); call move(x1+20,y1+105); call outstring("detach;"); call pause; call cls; DETACH; call aff(j); y.tuer := 1; sortir := 0; call reaffiche_boi(y,x,240,630,10,0); call aff_cor(x1,y1,x2,y2); call color(10); call move(x1+20,y1+115); call outstring("call t(y.right);"); call pause; call aff_cor(x1,y1,x2,y2); (* CONSECUTIVE ELEMENTS OF TREE Y ARE SENT FOR FURTHER *) (* PROCESSING TO THE MASTER PROGRAM *) CALL T(Y.RIGHT,w,xmax,ymax+60,haut+1); FI; call color(10); call move(x1+15,y1+125); call outstring("fi;"); call pause; call affiche_cor(x1,y1,x2,y2); call color(10); call move(x1+10,y1+135); call outstring("end t;"); call pause; call affiche_cor(x1,y1,x2,y2); call efface_zone; END T; BEGIN x1 := 410; x2 := 630; y1 := 30; y2 := 230; call affiche_cor(x1,y1,x2,y2); call color(10); call move(x1+5,y1+150); call outstring("begin"); call pause; call affiche_cor(x1,y1,x2,y2); call color(10); call move(x1+10,y1+160); call outstring("return;"); call pause; call affiche_cor(x1,y1,x2,y2); RETURN; xmin := 240; xmax := 630; ymax := 10; hmin := 240; hmax := 630; vmax := 10; call aff(i); x1 := 10; x2 := 230; y1 := 10; y2 := 210; call affiche_cor(x1,y1,x2,y2); call color(10); call move(x1+10,y1+170); call outstring("call t(x);"); call pause; call affiche_cor(x1,y1,x2,y2); CALL T(X,240,630,10,0); call color(10); call move(x1+10,y1+180); call outstring("val:=m;"); call pause; call affiche_cor(x1,y1,x2,y2); VAL := M; valeur := m; call affiche_cor(x1,y1,x2,y2); call pause; call color(10); call move(x1+5,y1+190); call outstring("end travers;"); call pause; call cls; call affiche_prg; (* VAL IS MAXIMAL VALUE TREATED AS A SENTINEL WHILE ENTIRE TREE IS *) (* TRAVESED *) END TRAVERS; unit saisir : iiuwgraph procedure; var cpt, w, z : integer; begin w := 120; z := 0; call color(3); call move(10,30); call outstring(" Les elements de l'arbre sont des entiers"); call move(10,50); call outstring(" Pour terminer l'insertion des elements de l'arbre, tapez 0"); call move(10,70); call outstring(" Ce nombre n'est pas insere dans l'arbre"); call color(3); call move(10,100); call outstring(" Donnez la sequence des elements de l'arbre numero "); call ecrit(i); call move(10,w); for cpt := 1 to borne do z := z + 1; if z = 10 then w := w + 10; call move(10,w); z := 0; fi; call ecrit(arbre(cpt)); od; end saisir; unit sequence : iiuwgraph procedure; var cpt, w, z : integer; begin w := 30; z := 0; call color(3); call move(10,10); call outstring("La fusion des sequences est : "); call move(10,w); for cpt := 1 to borne do z := z + 1; if z = 10 then w := w+10; call move(10,w); z := 0; fi; call ecrit(res(cpt)); od; end sequence; (*************************************************************) VAR N,I,J,MIN,M,K, choix,x1,x2,y1,y2,valeur,u : INTEGER, h,v,p,abscisse,ordonnee,xmin,xmax,ymax : integer, hmin,hmax,vmax,hauteur,haut,sortir,borne,longueur : integer, driver,droit,gauche,centre : boolean, touche : char, rep : char, arbre,res : arrayof integer, (* N - TNE NUMBER OF TREES M - MAXIMAL KEY VALUE + 1 MIN- MINIMAL VALUE PRODUCED AT A GIVEN MOMENT BY SYSTEM OF COROUTINES*) D : ARRAYOF NODE, TR : ARRAYOF TRAVERS; BEGIN pref iiuwgraph block begin abscisse := 0; ordonnee := 30; driver := false; call hpage(0,0,0); call hpage(0,639,349); call gron(0); call presentation; gauche := false; droit := false; centre := false; call border(5); call color(3); call cls; call affiche_prg; call color(10); call move(10,98); call outstring("begin"); call pause; DO call affiche_prg; call color(10); call move(20,107); call outstring("writeln('Donnez le nombre d'arbres :');"); call pause; call cls; call color(3); call move(10,10); call outstring(" Donnez le nombre d'arbres : "); call pause; call cls; call affiche_prg; call color(10); call move(332,107); call outstring("read(n);"); call pause; call cls; call color(3); call move(10,10); call outstring(" Donnez le nombre d'arbres : "); read(N); IF N>0 THEN EXIT; ELSE call move(10,30); call outstring(" Ce nombre doit etre superieur a 0"); call pause; call cls; FI; OD; call move(250,10); call ecrit(N); call pause; call cls; call affiche_prg; call color(10); call move(20,116); call outstring("array d dim(1:n);"); call pause; ARRAY D DIM(1:N); call affiche_prg; x1:=450; x2:=485; y1:=30; y2:=45; call affiche_abr(x1,y1,x2,y2); call pause; call cls; longueur := 0; FOR I := 1 TO N DO borne := 0; array arbre dim(1:50); call affiche_prg; call color(10); call move(20,125); call outstring("for i:=1 to n do"); call pause; call affiche_prg; call color(10); call move(30,134); call outstring("writeln('Donnez la sequence de l'arbre no :');"); call pause; call cls; call saisir; call pause; call cls; do call affiche_prg; call color(10); call move(30,143); call outstring("read(j);"); call pause; call cls; call saisir; call move(10,200); read(J); if j > 0 then exit; fi; call cls; od; borne := borne + 1; arbre(borne) := j; longueur := longueur + 1; call saisir; call pause; call cls; call affiche_prg; call color(10); call move(102,143); call outstring("if j>m"); call pause; IF J>M THEN call affiche_prg; call color(10); call move(158,143); call outstring("then"); call pause; call affiche_prg; call color(10); call move(198,143); call outstring("m:=j"); call pause; M :=J; call affiche_prg; call color(10); call move(238,143); call outstring("fi;"); call pause; FI; call affiche_prg; call color(10); call move(30,152); call outstring("d(i):=new node;"); call pause; D(I) := NEW NODE; call affiche_prg; call color(10); call move(158,152); call outstring("d(i).val:=j;"); call pause; D(I).VAL := J; DO call affiche_prg; call color(10); call move(30,161); call outstring("do"); call pause; do call affiche_prg; call color(10); call move(40,170); call outstring("read(j);"); call pause; call cls; call saisir; call move(10,200); read(j); if j =/= 0 then borne := borne + 1; arbre(borne) := j; longueur := longueur + 1; call saisir; call pause; fi; call cls; call affiche_prg; call color(10); call move(112,170); call outstring("if j=0"); call pause; IF J = 0 THEN call affiche_prg; call color(10); call move(168,170); call outstring("then"); call pause; call affiche_prg; call color(10); call move(208,170); call outstring("exit"); call pause; EXIT exit; FI; call affiche_prg; call color(10); call move(248,170); call outstring("fi;"); call pause; if j > 0 then exit fi; od; call affiche_prg; call color(10); call move(40,179); call outstring("if j>m"); call pause; IF J > M THEN call affiche_prg; call color(10); call move(96,179); call outstring("then"); call pause; call affiche_prg; call color(10); call move(136,179); call outstring("m:=j"); call pause; M := J; call affiche_prg; call color(10); call move(176,179); call outstring("fi;"); call pause; FI; call affiche_prg; call color(10); call move(208,179); call outstring("call d(i).ins(j);"); call pause; CALL D(I).INS(J); call affiche_prg; call color(10); call move(30,188); call outstring("od;"); call pause; OD; call affiche_prg; call color(10); call move(20,197); call outstring("od;"); call pause; kill(arbre); OD; call affiche_prg; call menu(choix); if choix = 1 then call groff; call endrun; else call move(19,327); for u:=328 to 348 do call move(20,u); call outstring(" "); od; call color(10); call move(20,206); call outstring("m:=m+1;"); call pause; M := M+1; fi; call affiche_prg; call color(10); call move(84,206); call outstring("array tr dim(1:n);"); call pause; ARRAY TR DIM(1:N); call affiche_prg; call color(10); call move(236,206); call outstring("min:=0;"); call pause; MIN := 0; FOR I:=1 TO N DO call affiche_prg; call color(10); call move(20,215); call outstring("for i:=1 to n do"); call pause; call affiche_prg; call color(10); call move(30,224); call outstring("tr(i):=new travers(d(i));"); call pause; call color(13); call move(580,10); call outstring("tr("); call ecrit(i); call move(630,10); call outstring(")"); call move(595,22); call outstring("\/"); call move(602,18); call draw(602,26); call color(9); call move(310,55); call draw(400,55); call move(400,52); call outstring(">"); call color(2); call move(465,30); call draw(465,20); call draw(400,20); call move(400,17); call outstring("<"); call color(11); call move(570,30); call draw(570,10); call draw(400,10); call move(400,7); call outstring("<"); TR(I) := NEW TRAVERS (D(I)); call affiche_prg; x1 := 410; x2 := 630; y1 := 30; y2 := 230; call affiche_cor(x1,y1,x2,y2); call affiche_prg; call color(10); call move(238,224); call outstring("attach(tr(i));"); call pause; call cls; x1 := 10; x2 := 230; y1 := 10; y2 := 210; call affiche_cor(x1,y1,x2,y2); ATTACH(TR(I)); call affiche_prg; call color(10); call move(20,233); call outstring("od;"); call pause; OD; call affiche_prg; call menu(choix); if choix = 1 then call groff; call endrun; else call move(19,327); for u:=328 to 348 do call move(20,u); call outstring(" "); od; call color(10); call move(20,242); call outstring("writeln('La fusion de la sequence est :');"); call pause; fi; call cls; borne := 0; array res dim(1:longueur); call sequence; call pause; call cls; DO call affiche_prg; call color(10); call move(20,251); call outstring("do"); call pause; call affiche_prg; call color(10); call move(30,260); call outstring("if min=m"); call pause; IF MIN = M THEN call affiche_prg; call color(10); call move(102,260); call outstring("then"); call pause; call affiche_prg; call color(10); call move(142,260); call outstring("exit"); call pause; EXIT; FI; call affiche_prg; call color(10); call move(182,260); call outstring("fi;"); call pause; call affiche_prg; call color(10); call move(214,260); call outstring("min:=tr(1).val;"); call pause; MIN := TR(1).VAL; call affiche_prg; call color(10); call move(342,260); call outstring("j:=1;"); call pause; J :=1; FOR I:= 2 TO N DO call affiche_prg; call color(10); call move(30,269); call outstring("for i:=2 to n do"); call pause; call affiche_prg; call color(10); call move(40,278); call outstring("if min>tr(i).val"); call pause; IF MIN>TR(I).VAL THEN call affiche_prg; call color(10); call move(176,278); call outstring("then"); call pause; call affiche_prg; call color(10); call move(216,278); call outstring("min:=tr(i).val;"); call pause; MIN:= TR(I).VAL; call affiche_prg; call color(10); call move(336,278); call outstring("j:=i;"); call pause; J := I; call affiche_prg; call color(10); call move(376,278); call outstring("fi;"); call pause; FI; call affiche_prg; call color(10); call move(30,287); call outstring("od;"); call pause; OD; call affiche_prg; call color(10); call move(30,296); call outstring("if min