8 (***************************************************************************)
\r
10 (* Projet 1 li1 par PAUL olivier et FERNANDEZ raphael *)
\r
11 (* GESTION D'UNE TABLE DE HACHAGE *)
\r
14 (***************************************************************************)
\r
22 (***************************************************************************)
\r
24 (* Definition d'une classe contenant les principaux *)
\r
25 (* Outils utilises par la suite ... *)
\r
26 (***************************************************************************)
\r
28 unit tools: class; (* les outils *)
\r
30 unit inchar:IIUWGraph function:integer;
\r
35 if i<>0 then exit fi; (* attend q'un caractere soit saisi et *)
\r
36 od; (* renvoie son code *)
\r
40 unit gotoxy:procedure(col,lig:integer);
\r
46 c:= chr(48+i); (* positionne le curseur *)
\r
47 d:= chr(48+j); (* en utilisant le driver ANSI *)
\r
52 write( chr(27), "[", c, d, ";", e, f, "H")
\r
55 unit cls : procedure;
\r
57 write(chr(27),"[2J"); (* efface l'ecran *)
\r
60 unit reverse:procedure;
\r
62 write( chr(27),"[5m"); (* passe en mode blink *)
\r
65 unit normal:procedure;
\r
67 write( chr(27),"[0m"); (* passe en mode normal *)
\r
70 unit box : procedure(x,y,z,w:integer);
\r
75 for i:=2 to (z-1) do write("Í") od;
\r
77 for i:=1 to (w-1) do
\r
78 call gotoxy(x,y+i); (* affiche une boite au coord x,y *)
\r
79 write("º"); (* de largeur z et de hauteur w *)
\r
80 call gotoxy(x+z-1,y+i);
\r
85 for i:=2 to (z-1) do write("Í") od;
\r
89 unit line:procedure;
\r
93 for t:=1 to 79 do write("_") od;
\r
94 call gotoxy(1,24); (* trace une ligne et positionne le curseur *)
\r
95 for t:=1 to 79 do write(" ") od;
\r
99 unit decbin:function(input e:integer):arrayof integer;
\r
102 array result dim(0:7);
\r
103 for f:=0 to 7 do result(f):=0 od;
\r
105 g:=0; (* convertisseur decimal-binaire *)
\r
107 result(g):=f mod 2;
\r
108 f:=f div 2; (* on utilise les restes de la division par 2 *)
\r
113 unit exp:function(x:integer):integer;
\r
116 result:=1; (* calcule 2^x *)
\r
117 for t:=1 to x do result:=result*2 od;
\r
120 unit bindec:function(input e:arrayof integer;l:integer):integer;
\r
126 result:=result+exp(i)*e(i); (* conversion binaire-decimal *)
\r
131 unit delay:procedure;
\r
133 call line; (* attend qu 'une touche soit pressee *)
\r
134 write("Appuyez sur une touche pour la suite");
\r
135 while inchar=0 do od;
\r
141 (***************************************************************************)
\r
143 (* Definition des elements et des operations s'y rapportant *)
\r
145 (***************************************************************************)
\r
147 unit dicob : class; (* le type d 'element saisi *)
\r
148 var mot :arrayof char, (* un mot de 25 lettres max *)
\r
149 trad :arrayof char; (* sa traduction en anglais *)
\r
151 array mot dim (1:25);
\r
152 array trad dim (1:100);
\r
155 unit newdicob : function : dicob; (* cree un nouvel element *)
\r
159 for t:=1 to 100 do result.trad(t):=' ' od; (* et l 'initialise *)
\r
160 for t:=1 to 25 do result.mot(t):=' ' od;
\r
163 unit readel : tools function(f:file) : dicob;
\r
164 var t:integer, (* lit un element *)
\r
170 write("saisissez votre mot puis <enter> pour valider");
\r
171 call box(1,15,79,2); (* si l' element provient du clavier *)
\r
172 call gotoxy(2,16); (* on agremente la presentation *)
\r
176 if (f<>NONE) then read(f,c) else read(c) fi;
\r
177 if (ord(c)=enter) then read(c) fi;
\r
179 if (f<>NONE) then (* saisie du nom *)
\r
180 while ((t<24) and not(eoln(f)))
\r
182 tamp.mot(t):=c; (* si l' element provient d'un fichier *)
\r
187 while ((t<24) and (ord(c)<>enter))
\r
190 read(c); (* si l' element provient du clavier *)
\r
193 if (t=24) then readln fi;
\r
196 tamp.mot(t+1):=chr(enter); (* on en marque la fin par enter *)
\r
197 if (f<>NONE) then readln(f) fi;
\r
201 write("saisissez votre mot puis <enter> pour valider");
\r
202 call box(1,15,79,3); (* si l' element provient du clavier *)
\r
204 write("traduction : ");
\r
207 if (f<>NONE) then read(f,c) else read(c) fi;
\r
208 if (f<>NONE) then (* saisie de la traduction *)
\r
209 while ((t<100) and not(eoln(f)))
\r
212 read(f,c); (* si l' element provient d'un fichier *)
\r
216 while ((t<100) and (ord(c)<>enter))
\r
219 read(c); (* si l' element provient du clavier *)
\r
224 tamp.trad(t+1):=chr(enter); (* on en marque la fin par enter *)
\r
225 if (f<>NONE) then readln(f) fi;
\r
229 unit writel : tools procedure(e:dicob);(* ecriture de l 'element *)
\r
233 call box(1,15,79,3);
\r
235 while ((ord(e.mot(t))<>enter) and (t<=25))
\r
237 write(e.mot(t)); (* ecriture du mot *)
\r
240 write(" se traduit par ");
\r
242 while ((ord(e.trad(t))<>enter) and (t<=25))
\r
244 write(e.trad(t)); (* et de la traduction *)
\r
249 unit supel :function(e1:dicob,e2:dicob):boolean;
\r
252 begin (* cherche si e1>e2 *)
\r
253 res:=0; (* res=0 si e1=e2 ,res=-1 si e2>e1,res=1 si e1>e2 *)
\r
255 while ((t<25) and (res=0) and (ord(e1.mot(t))<>enter)
\r
256 and (ord(e2.mot(t))<>enter))
\r
258 if (ord(e1.mot(t))<ord(e2.mot(t))) then res:=-1 fi;
\r
259 if (ord(e1.mot(t))>ord(e2.mot(t))) then res:=1 fi;
\r
262 if (ord(e1.mot(t))=enter) and (ord(e2.mot(t))<>enter) and (res=0)
\r
263 then res:=-1 fi; (* le plus long est le plus grand *)
\r
264 if (ord(e2.mot(t))=enter) and (ord(e1.mot(t))<>enter) and (res=0)
\r
265 then res:=1 fi; (* idem *)
\r
269 unit egalel :function(input e1,e2:dicob):boolean;
\r
270 var t:integer, (* cherche si deux elements sont egaux *)
\r
275 while ((t<25) and (res=0) and (ord(e1.mot(t))<>enter)
\r
276 and (ord(e2.mot(t))<>enter))
\r
278 if (e1.mot(t)<>e2.mot(t)) then res:=1 fi;
\r
281 if (ord(e1.mot(t))<>ord(e2.mot(t))) then res:=1 fi;
\r
285 unit extraction : tools function(e1:dicob;long:integer):integer;
\r
286 var t:integer, (* function de hachage par extraction *)
\r
287 tamp:arrayof integer,
\r
288 rep:arrayof arrayof integer;
\r
290 array tamp dim(0:31);
\r
291 for t:=0 to 31 do tamp(t):=0 od;
\r
292 array rep dim(1:extrnb);
\r
293 for t:=1 to extrnb do rep(t):=decbin(ord(e1.mot(t))) od;(* conversion *)
\r
294 for t:=1 to extrnb do tamp(t-1):=rep(t)(t-1) od;(*on prend les extrnb*)
\r
295 result:=((bindec(tamp,32) mod long)+1);(* premiers bits *)
\r
296 (* voir remarque fonction suivante pour mod *)
\r
298 for t:=1 to extrnb do kill(rep(t)) od;
\r
301 unit compression : tools function(e1:dicob;long:integer):integer;
\r
302 var t,l,nb0,nb1,u:integer, (* function de hachage par compression *)
\r
303 tamp:arrayof integer,
\r
304 rep:arrayof arrayof integer;
\r
306 array tamp dim(0:7);
\r
307 for t:=0 to 7 do tamp(t):=0 od;
\r
309 while ((ord(e1.mot(l))<>enter) and (l<25)) do l:=l+1 od;
\r
310 l:=l-1; (* longueur du mot *)
\r
311 array rep dim(1:l+1);
\r
312 for t:=1 to l do rep(t):=decbin(ord(e1.mot(t))) od;
\r
316 if (rep(t)(u)=0) then nb0:=nb0+1 fi; (* on calcule le nombre de 1 et *)
\r
317 if (rep(t)(u)=1) then nb1:=nb1+1 fi; (* de 0 pour chaque bit *)
\r
319 if ((nb1 mod 2)=1) then tamp(u):=1 (* Xor *)
\r
320 else tamp(u):=0 fi;
\r
322 result:=((bindec(tamp,8) mod long)+1);(* reconversion*)
\r
324 for t:=1 to l do kill(rep(t)) od;
\r
325 end compression;(*le mod permet de prendre une longueur de tableau variable*)
\r
326 (* au detriment de la "precision" de la fonction *)
\r
328 unit division : tools function(e1:dicob;long:integer):integer;
\r
329 var t,l,u,v:integer, (* function de hachage par division *)
\r
330 tamp:arrayof integer,
\r
331 rep:arrayof arrayof integer;
\r
334 while ((ord(e1.mot(l))<>enter) and (l<25)) do l:=l+1 od;
\r
336 array rep dim(1:l+1);
\r
337 array tamp dim(0:8*(l));
\r
338 for t:=0 to 8*l-1 do tamp(t):=0 od;
\r
339 for t:=1 to l do rep(t):=decbin(ord(e1.mot(t))) od; (* conversion *)
\r
342 for t:=0 to 8*l-1 do
\r
343 tamp(t):=rep(u)(v);
\r
345 if (v=8) then (* on recopie les conversions dans un seul tableau *)
\r
350 result:=(bindec(tamp,8*l) mod long)+1; (* que l 'on convertit *)
\r
352 for t:=1 to l+1 do kill(rep(t)) od;
\r
355 unit multiplication : tools function(e1:dicob;long:integer):integer;
\r
356 var pos:real, (* function de hachage par multiplication *)
\r
358 tamp:arrayof integer,
\r
359 rep:arrayof arrayof integer;
\r
362 while ((ord(e1.mot(l))<>enter) and (l<25)) do l:=l+1 od;
\r
364 array rep dim(1:l+1);
\r
365 array tamp dim(0:8*(l));
\r
366 for t:=0 to 8*l-1 do tamp(t):=0 od;
\r
367 for t:=1 to l do rep(t):=decbin(ord(e1.mot(t))) od;
\r
369 v:=0; (* idem division *)
\r
370 for t:=0 to 8*l-1 do
\r
371 tamp(t):=rep(u)(v);
\r
378 pos:=bindec(tamp,8*l)*theta; (* conversion *)
\r
379 result:=(entier((pos-entier(pos))*long)+1);
\r
381 for t:=1 to l+1 do kill(rep(t)) od;
\r
382 end multiplication;
\r
384 (***************************************************************************)
\r
386 (* Definition de la classe table ainsi que des operations *)
\r
387 (* utilisees par celle-ci ... *)
\r
388 (***************************************************************************)
\r
390 unit table : tools class (type elem;function newelem:elem;
\r
391 function egalelem(e1,e2:elem):boolean;function readelem(f:file):elem;
\r
392 function supelem(e1,e2:elem):boolean;
\r
393 function hachelem(e1:elem;l:integer):integer;procedure writelem(e:elem));
\r
395 unit tree: class (el: elem); (* definition d 'un arbre binaire de recherche *)
\r
396 var left,right: tree;
\r
399 unit max:function (input t:tree):tree;
\r
406 tamp:=NONE; (* calcule le plus grand element d 'un arbre *)
\r
411 if (tamp.right<>NONE) then
\r
412 tamp:=tamp.right; (* celui-ci se trouve en bas a droite *)
\r
413 else continue:=FALSE;
\r
419 writeln("maximum trouve ... fait.");
\r
422 unit find:function(input t:tree;e:elem):tree;
\r
424 continue,ok :boolean; (* recherche d 'un elemnt *)
\r
435 if supelem(e,tamp.el) then
\r
436 if (tamp.right<>NONE) then
\r
437 tamp:=tamp.right; (* si l'arbre courant est plus petit on va a droite *)
\r
438 else continue:=FALSE;
\r
441 if egalelem(e,tamp.el) then
\r
442 continue:=FALSE; (* si l'arbre courant est celui recherche on arrete *)
\r
445 if (tamp.left<>NONE) then
\r
446 tamp:=tamp.left; (* sinon on va a gauche *)
\r
447 else continue:=FALSE;
\r
454 writeln("element trouve ... fait.");
\r
455 if ok then result:=tamp;
\r
456 else result:=NONE fi;
\r
459 unit add: function (input t: tree; e: elem):tree;
\r
460 var tamp1,tamp2: tree,
\r
461 continue :boolean; (* ajout d 'un element a un arbre *)
\r
471 if supelem(e,tamp1.el) then
\r
472 if (tamp1.right<>NONE) then
\r
473 tamp1:=tamp1.right; (* idem recherche *)
\r
474 else continue:=FALSE fi;
\r
476 if (tamp1.left<>NONE) then
\r
478 else continue:=FALSE fi;
\r
481 tamp2:=new tree(e);(* on cree un nouvel arbre *)
\r
484 if supelem(e,tamp1.el) then tamp1.right:=tamp2;
\r
485 else tamp1.left:=tamp2 fi;(*on le place*)
\r
487 writeln("ajout classique ... fait.");
\r
492 unit last:function(input t:tree;input e:tree;output r:boolean):tree;
\r
493 var tamp: tree, (* recherche l'element precedent un autre *)
\r
494 continue,ok :boolean;
\r
504 if (tamp.right<>NONE) then
\r
505 if egalelem(e.el,tamp.right.el) then
\r
507 ok:=TRUE; (* idem recherche mais avec 2 possibilites *)
\r
511 if (tamp.left<>NONE) then
\r
512 if egalelem(e.el,tamp.left.el) then
\r
519 if supelem(e.el,tamp.el) then
\r
520 if (tamp.right<>NONE) then
\r
522 else continue:=FALSE; (* deplacement *)
\r
525 if (tamp.left<>NONE) then
\r
527 else continue:=FALSE;
\r
534 writeln("element precedent trouve ... fait.");
\r
535 if ok then result:=tamp;
\r
536 else result:=NONE fi;
\r
539 unit sub: function (input t: tree;e:elem):tree;
\r
540 var tamp2,tamp3,pred1,pred2: tree,
\r
541 r1,r2:boolean; (* on enleve une element a un arbre *)
\r
543 tamp2:=find(t,e); (* on recherche la place de l' element *)
\r
544 pred1:=last(t,tamp2,r1);(* son pere *)
\r
545 if (tamp2<>NONE) then
\r
546 if (tamp2=t) and (tamp2.left=NONE) then
\r
549 if (tamp2.left=NONE) then
\r
551 pred1.right:=tamp2.right;
\r
553 pred1.left:=tamp2.right; (* on raccorde *)
\r
557 tamp3:=max(tamp2.left);(* on cherche le max du sous arbre gauche *)
\r
558 pred2:=last(t,tamp3,r2);(* et son pere *)
\r
559 if (tamp3<>NONE) then
\r
561 if (pred1<>NONE) then pred1.right:=tamp3;
\r
564 if (pred2<>tamp2) then pred2.right:=tamp3.left fi;
\r
565 tamp3.right:=tamp2.right;
\r
566 tamp3.left:=pred2; (* on connecte *)
\r
568 if (pred1<>NONE) then pred1.left:=tamp3;
\r
571 if (pred2<>tamp2) then pred2.right:=tamp3.left fi;
\r
572 tamp3.right:=tamp2.right;
\r
581 writeln("element non touve ...");
\r
584 writeln("deletion terminee ... fait.");
\r
588 unit proof:function(input t:tree):integer;
\r
589 begin (* calcule la profondeur d 'un arbre recursivement*)
\r
591 result:=imax(proof(t.left),proof(t.right))+1;
\r
592 else(* proof=max(proof(arbredroit),proof(arbregauche)) *)
\r
597 unit total:procedure(input t:tree;input x,y,z:integer;input current:tree);
\r
598 var i:integer;(* affiche un arbre recursivement *)
\r
601 if (t.right<>NONE) and (t.left=NONE) then
\r
604 y:=y+1; (* si le sous arbre droit existe on l' affiche *)
\r
607 for i:=2 to (exp(z-2)) do write("Í") od;
\r
609 call total(t.right,x,y,z-1,current);
\r
611 if (t.left<>NONE) and (t.right=NONE) then
\r
614 y:=y+1; (* si le sous arbre gauche existe on l' affiche *)
\r
615 call gotoxy(x-exp(z-2),y);
\r
616 for i:=1 to (exp(z-2)) do write("Í") od;
\r
619 call total(t.left,x,y,z-1,current);
\r
621 if (t.left<>NONE) and (t.right<>NONE) then
\r
625 call gotoxy(x,y);(* si les deux existent on les affiche les deux *)
\r
627 for i:=2 to (exp(z-2)) do write("Í") od;
\r
629 call total(t.right,x,y,z-1,current);
\r
635 call gotoxy(x-exp(z-2),y);
\r
636 for i:=1 to (exp(z-2)) do write("Í") od;
\r
639 call total(t.left,x,y,z-1,current);
\r
641 call gotoxy(x,y);(* sinon on affiche l'element *)
\r
646 unit tableau : procedure (input e,f:integer);
\r
647 begin (* on affiche le tableau correspondant au code de hachage *)
\r
648 if ((e<f) or (e=f)) and ((e>1) or (e=1)) then
\r
649 call box(30,10,10,10);
\r
650 call gotoxy(31,15); (* tableau recherche *)
\r
655 if (e+1<f) or (e+1=f) then
\r
656 call box(50,10,10,10); (* le suivant *)
\r
657 call gotoxy(51,15);
\r
660 if (e-1>1) or (e-1=1) then
\r
661 call box(10,10,10,10); (* le precedent *)
\r
662 call gotoxy(11,15);
\r
667 unit newtable : function (input long : integer) :arrayof tree;
\r
668 var t : integer;(* cree une nouvelle table *)
\r
670 array result dim (1:long);
\r
671 for t:=1 to long do result(t):=NONE od;
\r
673 writeln("table initialisee ... fait.");
\r
676 unit ajoute :function(input T:arrayof tree;long:integer):arrayof tree;
\r
677 var lg,pos:integer, (* ajoute un element a la table *)
\r
681 e:=readelem(none); (* lit l'element *)
\r
683 pos:=hachelem(e,long);(* calcule son hach code *)
\r
685 writeln("hach code calcule ... fait. ",pos);
\r
686 call tableau(pos,long);(* marque sa position *)
\r
688 writeln("tableau designe ... fait.");
\r
689 current:=find(T(pos),e);(* le cherche *)
\r
690 if (current=NONE) then
\r
691 T(pos):=add(T(pos),e);(* s'il n'existe pas l'ajoute *)
\r
693 writeln("element ajoute ... fait.");
\r
695 lg:=proof(T(pos)); (* calcule la profondeur de l'arbre *)
\r
696 if lg<6 then call total(T(pos),40,1,lg,current) else (* affiche l'arbre *)
\r
698 write("l'arbre est trop grand pour etre imprime ...");
\r
702 writeln("element deja stocke ...");
\r
705 call delay;(* attend que l'utilisateur ai vu l'arbre *)
\r
708 unit supp :function(input T:arrayof tree;long:integer):arrayof tree;
\r
709 var lg,pos:integer,(* supprime un element *)
\r
713 e:=readelem(none); (* idem ajoute *)
\r
715 pos:=hachelem(e,long);
\r
717 writeln("hach code calcule ... fait. ",pos);
\r
718 call tableau(pos,long);
\r
720 writeln("tableau designe ... fait.");
\r
721 current:=find(T(pos),e);
\r
722 if (current<>NONE) then
\r
723 T(pos):=sub(T(pos),e);
\r
725 writeln("element detruit ... fait.");
\r
728 if lg<6 then call total(T(pos),40,1,lg,current) else
\r
730 write("l'arbre est trop grand pour etre imprime ...");
\r
734 writeln("non trouve ...");
\r
740 unit recherche :procedure(input T:arrayof tree;long:integer);
\r
741 var pos:integer,(* recherche un element dans la table *)
\r
745 e:=readelem(none);(* idem ajoute *)
\r
747 pos:=hachelem(e,long);
\r
749 writeln("hach code calcule ... fait. ",pos);
\r
750 call tableau(pos,long);
\r
752 writeln("tableau designe ... fait.");
\r
753 current:=find(T(pos),e);
\r
755 if (current<>NONE) then call writelem(current.el);(* ecrit le resultat *)
\r
756 else writeln("non trouve ...") fi;(* de la recherche *)
\r
758 writeln("recherche terminee ... fait.");
\r
762 unit demo :function(input T:arrayof tree;long:integer):arrayof tree;
\r
763 var fich:file,(*stocke automatiquement des elements contenus dans un fichier*)
\r
769 open(fich,text,unpack("data.dem"));(* on ouvre le fichier *)
\r
771 writeln("ouverture du fichier ... fait.");
\r
772 call reset(fich); (* en lecture *)
\r
773 while not(eof(fich))
\r
775 e:=readelem(fich);(* idem ajoute *)
\r
776 pos:=hachelem(e,long);
\r
778 writeln("hach code calcule ... fait. ");
\r
779 call tableau(pos,long);
\r
781 writeln("tableau designe ... fait.");
\r
782 current:=find(T(pos),e);
\r
783 if (current=NONE) then
\r
784 T(pos):=add(T(pos),e);
\r
786 writeln("element ajoute ... fait.");
\r
789 if lg<6 then call total(T(pos),40,1,lg,current) else
\r
791 write("l'arbre est trop grand pour etre imprime ...");
\r
794 writeln("arbre imprime ... fait.");
\r
797 writeln("element deja stocke ...");
\r
803 unit numb:function(input T:tree):integer;
\r
804 begin (* calcule le nombre de sommets par arbre recursivement *)
\r
806 result:=numb(T.left)+numb(T.right);
\r
807 else (* nbsom=nbsom(arbregauche)+nbsom(arbredroit) *)
\r
812 unit stats:procedure(input T:arrayof tree;long:integer);
\r
813 var u,s1,s2,s3,max1,max2:integer,
\r
814 s,v:arrayof integer;(* calcule quelques satistiques sur les donnees *)
\r
815 (* stockees dans la table *)
\r
818 array s dim(1:long);
\r
819 array v dim(1:long);
\r
820 for u:=1 to long do
\r
821 if (T(u)<>NONE) then
\r
822 s1:=s1+1;(* nombre d'arbre utilises *)
\r
823 s(u):=numb(T(u))-1;
\r
825 s2:=s2+s(u);(* nombre total de sommets *)
\r
826 s3:=s3+v(u);(* profondeur totale de la table *)
\r
830 for u:=1 to long do
\r
831 if (s(u)>s(max1)) then max1:=u fi;
\r
832 if (v(u)>s(max2)) then max2:=u fi;
\r
836 write("Nombre Total de sommets :",s2);
\r
838 write("Nombre Total d 'arbres non vides :",s1);
\r
841 write("Nombre moyen de sommet par arbre :",s2/s1);
\r
842 call gotoxy(10,15);
\r
843 write("Profondeur moyenne :",s3/s1);
\r
846 write("Tableau non rempli ...");
\r
848 call gotoxy(10,11);
\r
849 write("Nombre de sommets de l'Arbre le plus important :",s(max1));
\r
850 call gotoxy(10,13);
\r
851 write("Profondeur de l'Arbre le plus grand :",v(max2));
\r
852 call box(7,3,70,15);
\r
854 write("stats calculees ... fait.");
\r
859 unit op:procedure(size:integer);
\r
860 var T:arrayof tree, (* menu *)
\r
867 write("utilisez les fleches haut/bas pour vous deplacer, droite pour
\r
872 writeln(" Inserer un element");writeln;
\r
873 writeln(" Rechercher un element");writeln;
\r
874 writeln(" Supprimer un element");writeln;
\r
875 writeln(" Demo");writeln;
\r
876 writeln(" Statistiques");writeln;
\r
877 writeln(" Quitter");writeln;
\r
878 call box(5,4,50,17);
\r
879 call box(10,4+2*i,35,2);
\r
882 if (c=-80) or (c=-72) then
\r
883 call gotoxy(10,4+2*i);
\r
885 call gotoxy(10,4+2*(i+1));
\r
887 call gotoxy(10,4+2*i+1);
\r
889 call gotoxy(44,4+2*i+1);
\r
891 if (c=-80) then i:=i+1 fi;
\r
892 if (c=-72) then i:=i-1 fi;
\r
893 if (i=7) then i:=1 fi;
\r
894 if (i=0) then i:=6 fi;
\r
895 call box(10,4+2*i,35,2);
\r
900 when 1 :T:=ajoute(T,size);
\r
901 when 2 :call recherche(T,size);
\r
902 when 3 :T:=supp(T,size);
\r
903 when 4 :T:=demo(T,size);
\r
904 when 5 :call stats(T,size);
\r
907 writeln("operations terminees ... fait.");
\r
913 (***************************************************************************)
\r
915 (* PROGRAMME PRINCIPAL *)
\r
917 (***************************************************************************)
\r
920 size,algo,i:integer,
\r
922 begin (* prog principal *)
\r
929 write("utilisez les fleches haut/bas pour vous deplacer, droite pour
\r
932 writeln(" EXTRACTION");writeln;
\r
933 writeln(" COMPRESSION");writeln;
\r
934 writeln(" DIVISION");writeln;
\r
935 writeln(" MULTIPLICATION");writeln;
\r
936 writeln(" QUITTER");writeln;
\r
937 call box(5,4,50,15);
\r
938 call box(10,4+2*i,35,2);
\r
941 if (c=-80) or (c=-72) then
\r
942 call gotoxy(10,4+2*i);
\r
944 call gotoxy(10,4+2*(i+1));
\r
946 call gotoxy(10,4+2*i+1);
\r
948 call gotoxy(44,4+2*i+1);
\r
950 if (c=-80) then i:=i+1 fi;
\r
951 if (c=-72) then i:=i-1 fi;
\r
952 if (i=6) then i:=1 fi;
\r
953 if (i=0) then i:=5 fi;
\r
954 call box(10,4+2*i,35,2);
\r
961 write("!! (petites tailles)+(beaucoup d'elts)=(pbs de memoire)");
\r
962 call box(20,15,35,2);
\r
963 call gotoxy(21,16);
\r
964 write("taille du tableau desire : ");
\r
971 pref table(dicob,newdicob,egalel,readel,supel,extraction,writel) block
\r
973 stTable:= new table(dicob,newdicob,egalel,readel,supel,
\r
974 extraction,writel);(* on definit les operations
\85 utiliser *)
\r
975 call op(size); (* dans la table sur elem *)
\r
979 pref table(dicob,newdicob,egalel,readel,supel,compression,writel) block
\r
981 stTable:= new table(dicob,newdicob,egalel,readel,supel,
\r
982 compression,writel);(* idem *)
\r
987 pref table(dicob,newdicob,egalel,readel,supel,division,writel) block
\r
989 stTable:= new table(dicob,newdicob,egalel,readel,supel,
\r
990 division,writel);(* idem *)
\r
995 pref table(dicob,newdicob,egalel,readel,supel,multiplication,writel) block
\r
997 stTable:= new table(dicob,newdicob,egalel,readel,supel,
\r
998 multiplication,writel);(* idem *)
\r