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
|
program pendu ;
var
i,rool,a,compt,erreur: integer ;
dico: text ;
mot : string ;
motacher,cherche : string ;
lettre : char ;
tab: array[1..22739] of string ;
begin
assign(dico,'liste_francais.txt');
reset(dico);
i:= 1 ;
while not eof(dico) do
begin
readln(dico,mot);
tab[i]:= mot ;
i:= i + 1 ;
end;
randomize ;
rool:= random(22739);
motacher:= tab[rool];
cherche:=tab[rool] ;
For a:=1 to length(motacher) do cherche[a]:='_' ;
repeat
writeln('Voici le mot à chercher',cherche) ;
writeln('Entrez une lettre ');
readln(lettre);
erreur:=0 ;
for a:=1 to length (motacher) do
begin
if lettre = motacher[a] then cherche[a]:=lettre
else erreur:= erreur + 1 ;
end ;
if erreur = length(motacher) then compt := compt +1 ;
until compt>=7 or motacher><cherche ;
if motacher = cherche then writeln('Bien joué ! vous avez trouvé le mot')
else writeln('Vous ètes mort dans d''affreuse souffrance brûlé vif !');
close(dico);
readln ;
end. |
Partager