Précédent   Forum du club des développeurs et IT Pro > Autres langages > Pascal
Pascal Forum d'entraide sur la programmation en langage Pascal et sur les EDI. Avant de poster -> la F.A.Q Pascal, les cours
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 05/01/2013, 14h16   #1
mhido007
Invité de passage
 
Homme mhidoo
Étudiant
Inscription : décembre 2012
Messages : 1
Détails du profil
Informations personnelles :
Nom : Homme mhidoo
Localisation : Maroc

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : décembre 2012
Messages : 1
Points : 0
Points : 0
Par défaut Jeu du pendu

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 :
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.
mhido007 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/01/2013, 17h37   #2
EpiTouille
Membre expérimenté
 
Avatar de EpiTouille
 
Homme Titouan Créac'h
Epitech
Inscription : mai 2009
Messages : 249
Détails du profil
Informations personnelles :
Nom : Homme Titouan Créac'h
Âge : 19
Localisation : France

Informations professionnelles :
Activité : Epitech

Informations forums :
Inscription : mai 2009
Messages : 249
Points : 527
Points : 527
Comme tu le sais, une chaine de caractère est un tableau de char (légerment différentes des char* en c) .

Tu peux donc parcourir la chaine avec une boucle.
A partir de ça, tu peux savoir si le caractère est ou non dans la chaine.

apres tu n'as plus qu'a bouclé et à afficher la lettre en conséquence
EpiTouille est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 09h48.


 
 
 
 
Partenaires

Hébergement Web