program hachage;

	const
		N = 71; {nombre de valeurs pour la fonction de hachage}
		N_1 = N - 1;
		M = 100;{taille du tableau}
		M_1 = M - 1;

	type
		chaine = string[20];
		element = record
				nom: chaine;
				suiv: integer;
			end;
		tableau = array[0..M_1] of element;

	var
		f: text;
		s: chaine;
		t: tableau;
		Nbnoms: integer; {nombre de noms courants, initialise a 0}
		Nc: integer;{nombre de collisions, initialise a 0}


{-----------------------partie hachage-----------------------------------------------}


	function h (s: chaine): integer;
{h(s) est compris entre 0 et N-1}
	begin
	end;

	procedure insertion (s: chaine);
{lors d'une insertion, une collision est visualisee}
	begin
	end;

	function recherche (s: chaine): boolean;
{lors d'un appel a recherche, le chemin de recherche est affiche}
	begin
	end;

	procedure suppression (s: chaine);
{supprime un element de la table}
	begin
	end;

{-----------------------partie transfert fichier--> table de hachage-----------------------}

	procedure initialisation (n: integer);
		var
			i: integer;
	begin
		for i := 0 to n do
			begin
				t[i].nom := '';
				t[i].suiv := -1;
			end;
		Nc := 0;
		Nbnoms := 0;
	end;

	procedure recopie (var f: text);
{Insere les cles du fichier dans la table de hachage}
	begin
		ShowText;
		while not eof(f) do
			begin
				readln(f, s);
				insertion(s);
			end;
	end;

{------------------------partie menu-------------------------------------------------}
	procedure menu;
	begin
		writeln('taper m (menu), c (chercher), s (supprimer) , i (inserer) ou q (quitter) ');
		writeln('puis un blanc et le nom a chercher si le choix n''est pas q ou m');
	end;

	procedure action;
		var
			i: integer;
			x: chaine;
			c: char;
	begin
		menu;
		repeat
			readln(x);
			c := x[1];
			if (c <> 'q') or (c <> 'm') then
				x := omit(x, 1, 2);
			case c of
				'q': 
					;
				'm': 
					menu;
				'c': 
					if recherche(x) then
						writeln(x, ' trouve')
					else
						writeln(x, ' non trouve');
				'i': 
					if recherche(x) then
						writeln(x, ' est deja dans la table')
					else
						insertion(x);
				's': 
					suppression(x);
			end;
		until c = 'q';
	end;


begin {principal}
	reset(f, 'Noms');
	initialisation(M_1);
	writeln('VISUALISATION DES COLLISIONS');
	recopie(f);
	writeln('Nbnoms=', Nbnoms : 2, '  Nc=', Nc : 2, '  N=', N : 2);
	action;
end. {principal}