Advertisement
Guest User

bac17

a guest
Apr 24th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. Program jeu;
  2. Uses Wincrt,crt;
  3. Var
  4. mot,mas: string;
  5.  
  6. Function verif (mot :String): Boolean;
  7. Var
  8. i: Integer;
  9. test: Boolean;
  10. Begin
  11. test := True;
  12. {for i:=1 to length(mot) do if not (mot[i] in ['a'..'z','A'..'Z'] ) then test:=false; }
  13. i := 0;
  14. Repeat
  15. i := i+1;
  16. test := (mot[i] In ['a'..'z','A'..'Z']);
  17. Until (test= False) Or (i=Length(mot));
  18. verif := (test) And (Length(mot) In [5..20]);
  19. End;
  20.  
  21. Function masquer (mot:String): string;
  22. Var
  23. i: Integer;
  24. cc: string;
  25. Begin
  26. cc := '';
  27. For i:=1 To Length(mot) Do
  28. cc := cc+'-';
  29. cc[1] := mot[1];
  30. cc[Length(cc)] := mot[Length(cc)];
  31. masquer := cc;
  32. End;
  33.  
  34. Procedure deviner (mot,mas:String);
  35. Var
  36. i,j: Integer;
  37. c: Char;
  38. Begin
  39. i := 0;
  40. Repeat
  41. i := i+1;
  42. Writeln ('le mot à deviner est :',mas);
  43. Writeln('il vous reste ',Length(mas)-i+1, ' essais');
  44. Writeln('proposer un caractère :');
  45. Readln(c);
  46.  
  47. for j:=1 To Length(mot) Do
  48. If (upcase(c)=upcase(mot[j])) Then mas[j] := mot[j];
  49. Until (i>Length(mot)) Or (mas=mot);
  50. If ( mas = mot ) Then write ('bravo ! ')
  51. Else write('désolé , ...');
  52. End;
  53. Begin
  54. Repeat
  55. write('saisir le mot à deviner :');
  56. Readln(mot);
  57. Until verif(mot);
  58. Clrscr();
  59. mas := masquer(mot);
  60. deviner (mot,mas)
  61. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement