3 (*******************************************************************)
\r
5 Unit newpage:procedure;
\r
7 write(chr(27),"[2J");
\r
10 (*******************************************************************)
\r
12 Unit gotoxy : procedure (row, column : integer);
\r
13 var c, d, e, f : char,
\r
24 write (chr(27), "[", c, d, ";", e, f, "H");
\r
27 (*******************************************************************)
\r
29 Unit pause:procedure(input seconde:integer);
\r
32 for temps:=1 to (9000*seconde) do od;
\r
35 (*******************************************************************)
\r
37 Unit affiche:procedure(input position:integer;
\r
38 inout tableau:arrayof integer);
\r
41 for i:=1 to upper(tableau) do
\r
42 if i=position then write(chr(27),"[33m");
\r
43 write(" ",tableau(i):4," ");
\r
44 write(chr(27),"[36m")
\r
46 write(" ",tableau(i):4," ") fi;
\r
51 (*******************************************************************)
\r
53 Unit A:process(n:integer;p:B);
\r
54 var tabA:arrayof integer,
\r
55 max,position,nb,i,nombre,j:integer,
\r
58 (********************)
\r
60 Unit rech_max:procedure(output max,position:integer);
\r
61 (* Recherche du plus grand
\82l
\82ment de tabA *)
\r
67 if tabA(i)>max then max:=tabA(i);
\r
73 (********************)
\r
77 write(chr(27),"[33m");
\r
78 writeln("- SAISIE DU TABLEAU A -");
\r
79 write(chr(27),"[36m");
\r
81 write("Quelle est la dimension de tabA ? ");
\r
83 array tabA dim (1:nb);
\r
85 write("Donnez tabA(",i:3,") : ");
\r
91 writeln("AFFICHAGE DES DIFFERENTES ETAPES DU TRI");
\r
97 call rech_max(max,position);
\r
99 if j<>0 then writeln("Etape ",j:2," : ") fi;
\r
102 call affiche(position,tabA);
\r
104 call p.echange(max,bo);
\r
105 tabA(position):=max;
\r
107 if bo then exit fi;
\r
110 write(chr(27),"[32m");
\r
111 writeln("Resultat Final : ");
\r
112 write(chr(27),"[36m");
\r
115 call affiche(position,tabA);
\r
119 (*******************************************************************)
\r
121 Unit B:process(n:integer);
\r
122 var tabB:arrayof integer,
\r
123 min,position,nb,i,nombre,j:integer,
\r
127 (********************)
\r
129 Unit rech_min:procedure(output min,position:integer);
\r
130 (* Recherche du plus petit
\82l
\82ment de tabB *)
\r
136 if tabB(i)<min then min:=tabB(i);
\r
142 (********************)
\r
144 Unit echange:procedure(inout max:integer;
\r
145 output bo:boolean);
\r
147 if min<max then tabB(position):=max;
\r
157 Unit rire:procedure;
\r
160 (********************)
\r
164 write(chr(27),"[33m");
\r
165 writeln("- SAISIE DU TABLEAU B -");
\r
166 write(chr(27),"[36m");
\r
168 write("Quelle est la dimension de tabB ? ");
\r
170 array tabB dim (1:nb);
\r
172 write("Donnez tabB(",i:3,") : ");
\r
181 call rech_min(min,position);
\r
185 call affiche(position,tabB);
\r
188 if (j mod 4)=0 then write(chr(27),"[32m");
\r
189 writeln("< Appuyez sur Retour >");
\r
190 write(chr(27),"[36m");
\r
195 if arret then exit fi;
\r
201 call affiche(position,tabB);
\r
204 (*******************************************************************)
\r
206 Unit baniere:procedure;
\r
209 write(chr(27),"[31m");
\r
211 writeln("PARTITION DE DEUX ENSEMBLES :");
\r
213 writeln("Min & Max");
\r
214 write(chr(27),"[36m");
\r
215 call gotoxy(15,29);
\r
216 writeln("Presented by");
\r
217 call gotoxy(22,26);
\r
218 write(chr(27),"[32m");
\r
219 writeln("- Dupin Christophe -");
\r
221 write(chr(27),"[36m");
\r
225 (************************* Programme principal *****************************)
\r
233 processusB:=new B(0);
\r
234 processusA:=new A(0,processusB);
\r
235 resume(processusA);
\r
236 resume(processusB);
\r