Corrigés Bac pratique Informatique
Transcription
Corrigés Bac pratique Informatique
Corrigés Bac pratique Informatique Sections Math, Sciences et Technique 28 mai 2012(8h30) lundi 28 mai 2012 à 8h30 program lundi_8h30; uses wincrt; type tab = array[1..20] of integer; var T:tab; N,P:integer; procedure saisie (var N:integer); begin repeat write('N = '); readln(N); until N in [5..20]; end; procedure saisiep(var p:integer); var ch:string; begin repeat readln(p); str(P,Ch); until length(ch) = 4; end; Devoirs et examens sur : www.kiteb.net procedure remplir(N:integer;var T:Tab); var i:integer; begin for i:=1 to N do begin write('T[',i,'] = '); T[i]:=random(9000)+1000; end; end; function aptot(N,P:integer;T:tab):boolean; var i:integer; b:boolean; begin B:=false; i:=0; repeat i:=i+1; if T[i]=p then b:=true; until(b) or (i=N); aptot:=B; end; 1/2 Correction proposée par Mme amina ESSAFI LADJIMI function appart(N,P:integer;T:tab):boolean; var i:integer; b:boolean; ch1,ch2:string; begin B:=false; i:=0; str(p,ch1); delete(ch1,4,1); repeat i:=i+1; str(T[i],ch2); delete(ch2,4,1); if ch1=ch2 then b:=true; until(b) or (i=N); appart:=B; end; procedure affichage(N:integer;T:tab); var i:integer; begin for i:= 1 to N do write(T[i]:5); end; begin saisie(N); write('P = '); saisiep(p); remplir(N,T); Affichage(N,T); Devoirs et examens sur : www.kiteb.net if aptot(N,p,T) then writeln(p,' appartient totalement à T') else if appart(N,P,T) then writeln(p,' appartient partiellement à T') else writeln(p,' n''appartient pas à T'); end. Correction proposée par Mme amina ESSAFI LADJIMI 2/2 Corrigés Bac pratique Informatique Sections Math, Sciences et Technique 28 mai 2012(10h) lundi 28 mai 2012 à 10h program lundi_10h_11h; uses wincrt; type tab=array[1..20] of string; var N,max:integer; T:Tab; procedure saisie(var N:integer); begin repeat write('N = '); readln(N); until N in [5..20]; end; Devoirs et examens sur : www.kiteb.net function verif(ch:string):boolean; var i:integer; b:boolean; begin i:=0; b:=true; repeat i:=i+1; if not(ch[i] in [' ','A'..'Z'] ) then b:=false; until (B = false) or (i=length(ch)); verif:=B; end; function calcul(ch:string):integer; var chv:string; i,nb:integer; begin chv:='AEOUIY'; nb:=0; for i:= 1 to length(ch) do if pos(ch[i],chv)<>0 then nb:=nb+1; calcul:=nb; end; function maximum(N:integer;T:TAB):integer; var i,max,nb:integer; begin max:=0; for i:= 1 to N do begin nb:=calcul(T[i]); 1/2 Correction proposée par Mme amina ESSAFI LADJIMI if nb>max then max:=nb; end; maximum:=max; end; procedure affichage(N,max:integer;T:TAB); var i,nb:integer; begin for i:= 1 to N do begin nb:=calcul(T[i]); if nb=max then writeln(T[i]); end; end; procedure remplir(N:integer;var T:Tab); var i:integer; begin for i:=1 to N do repeat write('T[',i,'] = '); readln(T[i]); until (verif(T[i])=true) and (length(T[i] <=20); end; Devoirs et examens sur : www.kiteb.net begin saisie(N); remplir(N,T); max:=maximum(N,T); affichage(N,max,T); end. Correction proposée par Mme amina ESSAFI LADJIMI 2/2 Corrigés Bac pratique Informatique Sections Math, Sciences et Technique 28 mai 2012(14h) lundi 28 mai 2012 à 14h program lundi_14h; uses wincrt; var ch:string; S:integer; function verif(ch:string):boolean; var i:integer; b:boolean; begin i:=0; b:=true; repeat i:=i+1; if not(ch[i] in ['0'..'9'] ) then b:=false; until (B = false) or (i=length(ch)); verif:=B; end; Devoirs et examens sur : www.kiteb.net procedure saisie(var ch:string); var N:longint; e:integer; begin repeat write('ch = '); readln(ch); until (length(ch) = 15) and (verif(ch)=true); end; Correction proposée par Mme amina ESSAFI LADJIMI 1/2 function somme(ch:string):integer; var i,x,y,e,s,s2:integer; ch2:string; begin S:=0; for i:=1 to Length(ch) do begin val(ch[i],x,e); if i mod 2 <> 0 then S:=S+x else begin y:= 2*x; if y>=10 then begin s2:=y div 10 + y mod 10; S:=S+S2; end else S:=S+y; end; end; somme:=s; end; begin saisie(ch); S:=somme(ch); if S MOD 10 = 0 then writeln(ch,' est valide') else writeln(ch,' est non Valide'); Devoirs et examens sur : www.kiteb.net end. Correction proposée par Mme amina ESSAFI LADJIMI 2/2 Corrigés Bac pratique Informatique Devoirs et examens sur : www.kiteb.net Sections Math, Sciences et Technique 28 mai 2012(15h30) lundi 28 mai 2012 à 15h30 program lundi_15h30; uses wincrt; var ch:string; S,cc,e,r,p:integer; function verif(ch:string):boolean; var i:integer; b:boolean; begin i:=0; b:=true; repeat i:=i+1; if not(ch[i] in ['0'..'9'] ) then b:=false; until (B = false) or (i=length(ch)); verif:=B; end; procedure saisie(var ch:string); var N:longint; e:integer; begin repeat write('ch = '); readln(ch); until (length(ch) = 13) and (verif(ch)=true); end; function somme(ch:string):integer; var i,x,e:integer; ch2:string; begin S:=0; for i:=1 to Length(ch)-1 do begin val(ch[i],x,e); if i mod 2 = 0 then S:=S+3*x else S:=S+x; end; somme:=s; end; begin saisie(ch); S:=somme(ch); r:=S mod 10; p:=10-r; val(ch[13],cc,e); if p=cc then writeln(ch,' est un code EAN13') else writeln(ch,' n''est pas un code EAN13'); Correction proposée par Mme amina ESSAFI LADJIMI end. 1/1 Corrigés Bac pratique Informatique Sections Math, Sciences et Technique 29 mai 2012(8h30) Mardi 29 mai 2012 à 8h30 program mardi8h; uses wincrt; type tab = array[1..26] of char ; var T:TAB; ch:string; i,P,Q:integer; Devoirs et examens sur : www.kiteb.net procedure saisieN (var N:integer); begin repeat write('Donner un entier dans [2..10] = '); readln(N); until N in [2..10]; end; function verif(ch:string):boolean; var i:integer; b:boolean; begin i:=0; b:=true; repeat i:=i+1; if not(ch[i] in ['A'..'Z',' '] ) then b:=false; until (B = false) or (i=length(ch)-1); verif:=B; end; procedure saisie(var ch:string); var N:longint; e:integer; begin repeat write('ch = '); readln(ch); until (ch[length(ch)] = '.') and (verif(ch)=true); end; Correction proposée par Mme amina ESSAFI LADJIMI 1/2 procedure crypter(var ch:string;p,q:integer); var i,j,k:integer; begin k:=0; repeat k:=k+1; if ch[k] in ['A'..'Z'] then begin i:=ord(ch[k])- 65 +1; j:=(p*i+q) MOD 26 +1; ch[k]:=T[j]; end; until k=length(ch)-1; end; Devoirs et examens sur : www.kiteb.net begin for i:=1 to 26 do T[i]:=chr(i+64); saisie(ch); saisieN(p); SaisieN(q); crypter(ch,p,q); writeln('Votre chaîne crypté = ',ch); end. Correction proposée par Mme amina ESSAFI LADJIMI 2/2 Corrigés Bac pratique Informatique Sections Math, Sciences et Technique 29 mai 2012(10h) Mardi 29 mai 2012 à 10h program mardi10h; uses wincrt; type tab = array[1..20] of string ; var T:TAB; P:integer; procedure saisieP (var P:integer); begin write('P = '); randomize; p:=random(3)+1; writeln(p); {readln(p);} end; Devoirs et examens sur : www.kiteb.net function verif(ch:string):boolean; var i:integer; b:boolean; begin i:=0; b:=true; repeat i:=i+1; if not(ch[i] in ['A'..'Z'] ) then b:=false; until (B = false) or (i=length(ch)); verif:=B; end; procedure remplir(var T:TAB); var i:integer; begin for i:=1 to 12 do repeat write('T[',i,'] = '); readln(T[i]); until (length(T[i])>=3) and (verif(T[i])=true); end; Correction proposée par Mme amina ESSAFI LADJIMI 1/2 procedure tri(var T:Tab;p:integer); var i:integer; b:boolean; ch:string; begin repeat b:=true; for i:= 1 to 11 do if T[i,p]>T[i+1,p] then begin ch:=T[i]; T[i]:=T[i+1]; T[i+1]:=ch; B:=False; end; until b=true; end; procedure affichage(T:tab); var i:integer; begin for i:=1 to 12 do begin write(T[i]:10); if i mod 3 = 0 then writeln; end; end; Devoirs et examens sur : www.kiteb.net begin remplir(T); saisiep(p); tri(T,p); affichage(T); end. Correction proposée par Mme amina ESSAFI LADJIMI 2/2 Corrigés Bac pratique Informatique Sections Math, Sciences et Technique 29 mai 2012(14h) Mardi 29 mai 2012 à 14h program mardi14h; uses wincrt; type typ_ch=string[120]; var ch,chr:typ_ch; function verif(ch:typ_ch):boolean; var i:integer; b:boolean; begin i:=0; b:=true; repeat i:=i+1; if not(ch[i] in ['A'..'Z'] ) then b:=false; until (B = false) or (i=length(ch)); verif:=B; end; Devoirs et examens sur : www.kiteb.net procedure saisie(var ch:typ_ch); begin repeat write('ch = '); readln(ch); until (verif(ch)=true); end; function crypter(ch:typ_ch):typ_ch; var i,x:integer; chr,ch0:string; begin chr:=''; for i:= 1 to length(ch) do begin x:=ord(ch[i]); str(x,ch0); chr:=chr+ch0; end; crypter:=chr; end; Correction proposée par Mme amina ESSAFI LADJIMI 1/2 procedure inverser(var chr:typ_ch); var i,l:integer; c:char; begin i:=0;l:=length(chr); repeat i:=i+1; c:=chr[i]; chr[i]:=chr[l-i+1]; chr[l-i+1]:=c; until (i=l div 2); end; Devoirs et examens sur : www.kiteb.net begin saisie(ch); chr:=crypter(ch); writeln('chr aprés étape1 = ',chr); inverser(chr); writeln('chr aprés étape2 = ',chr); end. Correction proposée par Mme amina ESSAFI LADJIMI 2/2