samedi 10 septembre 2016
    1. Program Cryptage;
    2. Var ch,ch2:string;
    3. (*************************************)
    4. Procedure saisie(var ch:string);
    5. Function verif(ch:string):boolean;
    6. Var i:integer;
    7. ok:boolean;
    8. Begin
    9. i:=0;
    10. Repeat
    11. i:=i+1;
    12. ok:= upcase(ch[i]) in ['A'..'Z',' '] Until (not ok) or (i=length(ch));
    13. verif:=ok;
    14. End;
    15. Begin
    16. Repeat
    17. Writeln('Phrase initiale = ');
    18. Readln(ch);
    19. Until (pos(' ',ch)= 0) and (verif(ch)=true);
    20. End;
    21. (***************************************)
    22. Function crypter(ch:string):string;
    23. var i,p:integer;
    24. Begin
    25. If ch[1]=' ' Then p:=0
    26. Else p:=1;
    27. For i:=1 to length(ch) do
    28. If ch[i]<>' ' Then
    29. If (ord(upcase(ch[i]))+p) <= ord('Z') Then ch[i]:=chr(ord(ch[i])+p)
    30. Else ch[i]:=chr(ord(ch[i])+p-26)
    31. Else p:=p+1;
    32. crypter:=ch
    33. End;
    34. (*********************P.P**********************)
    35. Begin
    36. saisie(ch);
    37. ch2:=crypter(ch);
    38. Writeln('Phrase cryptée = ',ch2);
    39. End.

0 commentaires:

Enregistrer un commentaire

Page Facebook

Turbo Pascal 32 bits

Turbo Pascal 64 bits