Bonjour,

je n'arrive pas à trouver un algo pour mon projet intitulé "jeu du pendu". Avec des commentaires appropriés, voilà ce que j'ai trouvé pour l'instant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
program pendu;
uses crt;
var
TabMots : array [0..19] of string;
imot,i,t,lm,posX,posY : integer;
s:char;
trouve : boolean;
 
begin
tabMots[0]:='cartographie';
tabMots[1]:='combinaison';
tabmots[2]:='conjuration';
tabmots[3]:='diplomatie';
tabMots[4]:='enthousiasme';
tabmots[5]:='fermentation';
tabmots[6]:='gasteropode';
tabMots[7]:='alterophile';
tabmots[8]:='humoristique';
tabmots[9]:='penitencier';
tabMots[10]:='avanturier';
tabMots[11]:='chlorophile';
tabmots[12]:='temperature';
tabmots[13]:='prevaricateur';
tabMots[14]:='paleantologue';
tabmots[15]:='melancolique';
tabmots[16]:='blasphematoire';
tabMots[17]:='lycanthropie';
tabmots[18]:='pharmaceutique';
tabmots[19]:='incomprehension';
repeat
randomize;
imot:=random(19);
clrscr;
write(imot);
t:=10;
gotoxy(1,7);
write('Vous avez 10 essais pour trouver le mot');
gotoxy(15,12);
lm:=length(tabmots[imot]);
for i:=1 to length(tabmots[imot]) do
    write('_ ');
posX:=whereX; posY:=whereY;
write('  ' , t, ' essais    ');
repeat
gotoxy(1,9);
clreol;
gotoxy(1,9);
write('Votre lettre : ');
readln(s);
s:=upcase(s);
trouve:=false;
for i:=1 to length(tabmots[imot]) do
    begin
    if s=upcase(tabmots[imot][i]) then
       begin
       gotoxy(15+((i-1)*2),12);
       write(s);
       tabmots[imot][i]:=' ';
       trouve:=true;
       lm:=lm-1;
       end;
    end;
if not trouve then
   begin
   t:=t-1;
   gotoxy(posX,posY);
   write('  ' , t, ' essais    ');
   end;
until (t=0) or (lm=0);
gotoxy(1,14);
if lm=0 then
   writeln('Bravo, vous avez gagn‚');
if t=0 then
   begin
   writeln('D‚sol‚, vous avez perdu');
   textcolor(4);
   for i:=1 to length(tabmots[imot]) do
      begin
      if tabmots[imot][i] <> ' ' then
         begin
          gotoxy(15+((i-1)*2),12);
          s:=upcase(tabmots[imot][i]);
          write(s);
         end;
      end;
   end;
textcolor(7);
{readln; }
gotoxy(1,16);
Write('Une autre partie? ');
read(s);
until not ((s='o') or (s='O'));
end.