Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

dimanche 26 avril 2020

Baccalauréat 2012 Sujet 5 Corrigé

Program S5; Var ph : string; p,q : integer; //************************************** Function verif(ch:String) : boolean; Var ok : boolean; i : integer; Begin ok := true; i := 1; While (ok) And (i<=length(ch)) Do If (ch[i] In ['A'..'Z',' ','.']) Then i := i+1 Else ok := false; verif := ok; End; //************************************** Function cryptage(ph:String;p,q:integer) : string; Var k,i,j : integer; phcryp : string; c : char; Begin phcryp := ''; For k:=1 To length(ph) Do If (ph[k] In ['A'..'Z']) Then Begin i := ord(ph[k])-64; j := ((p*i+q) Mod 26) +1; c := chr(j+64); phcryp := phcryp+c; End Else phcryp := phcryp+ph[k]; cryptage := phcryp; End; //************************************** Begin Repeat writeln('saisir une phrase: '); readln(ph); Until (ph<>'') And (ph[length(ph)]='.')And(verif(ph)); writeln; Repeat write('Saisir p: '); readln(p); Until (p In [2..10]); Repeat write('Saisir q: '); readln(q); Until (q In [2..10]); writeln; writeln('----------------------------------'); writeln('Phrase après cryptage: '); writeln('----------------------------------'); writeln; writeln('Phrase cryptée: ',cryptage(ph,p,q)); writeln; writeln('----------------------------------'); End.
 
Back to top