Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

dimanche 26 avril 2020

Baccalauréat 2015 Sujet 20 Corrigé

Program S20; Type chaine = string[8]; Var telephone : chaine; //********************************** Procedure init_tel(Var telephone:chaine); Var ch1,ch2 : string[4]; Begin str(random(9000)+1000,ch1); str(random(10000),ch2); If length(ch2)=3 Then telephone := ch1+'0'+ch2 Else If length(ch2)=2 Then telephone := ch1+'00'+ch2 Else If length(ch2)=1 Then telephone := ch1+'000'+ch2 Else telephone := ch1+ch2; End; //********************************** Function verif(ch:String) : boolean; Var i : integer; b : boolean; Begin i := 0; Repeat i := i+1; b := ch[i] In ['0'..'9']; Until (i=8) Or (Not(b)); verif := b; End; //********************************** Procedure proposition(telephone:chaine); Var c,reponse : char; nb_proposition,i : integer; rech_tele : chaine; telephone2 : chaine; Begin rech_tele := '--------'; telephone2 := telephone; nb_proposition := 0; Repeat nb_proposition := nb_proposition+1; Repeat write('Proposer un chiffre ? '); readln(c); Until c In ['0'..'9']; For i:=1 To 8 Do If telephone2[i]=c Then rech_tele[i] := c; writeln(rech_tele); If (nb_proposition<>5) And (rech_tele<>telephone) Then Repeat writeln('Voulez-vous proposer un numero ? (O/N) '); readln(reponse); Until Upcase(reponse) In['O','N']; Until (nb_proposition=5) Or (upcase(reponse)='O') Or (rech_tele=telephone); If (nb_proposition=5) Or (rech_tele<>telephone) Or (upcase(reponse)='O') Then Repeat writeln('Proposer un numero : '); readln(rech_tele); Until (length(rech_tele)=8) And (verif(rech_tele)); If rech_tele=telephone Then writeln('Bravo ! Vous avez gagne') Else Begin writeln('Desole ! Vous avez perdu'); writeln('Le numero est :',telephone); End; End; //********************************** Begin randomize; init_tel(telephone); proposition(telephone); End.
 
Back to top