Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Program jeu;
- Uses Wincrt,crt;
- Var
- mot,mas: string;
- Function verif (mot :String): Boolean;
- Var
- i: Integer;
- test: Boolean;
- Begin
- test := True;
- {for i:=1 to length(mot) do if not (mot[i] in ['a'..'z','A'..'Z'] ) then test:=false; }
- i := 0;
- Repeat
- i := i+1;
- test := (mot[i] In ['a'..'z','A'..'Z']);
- Until (test= False) Or (i=Length(mot));
- verif := (test) And (Length(mot) In [5..20]);
- End;
- Function masquer (mot:String): string;
- Var
- i: Integer;
- cc: string;
- Begin
- cc := '';
- For i:=1 To Length(mot) Do
- cc := cc+'-';
- cc[1] := mot[1];
- cc[Length(cc)] := mot[Length(cc)];
- masquer := cc;
- End;
- Procedure deviner (mot,mas:String);
- Var
- i,j: Integer;
- c: Char;
- Begin
- i := 0;
- Repeat
- i := i+1;
- Writeln ('le mot à deviner est :',mas);
- Writeln('il vous reste ',Length(mas)-i+1, ' essais');
- Writeln('proposer un caractère :');
- Readln(c);
- for j:=1 To Length(mot) Do
- If (upcase(c)=upcase(mot[j])) Then mas[j] := mot[j];
- Until (i>Length(mot)) Or (mas=mot);
- If ( mas = mot ) Then write ('bravo ! ')
- Else write('désolé , ...');
- End;
- Begin
- Repeat
- write('saisir le mot à deviner :');
- Readln(mot);
- Until verif(mot);
- Clrscr();
- mas := masquer(mot);
- deviner (mot,mas)
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement