Correction proposée par Mme Hajer NEFZAOUI Corrigés Bac pratique Informatique Section Math & Sciences & Technique 27 mai 2013(8h) program seance1; uses wincrt; Lundi 27 mai 2013 à 8h type star=string[8]; vec=array[1..100]of star; tab=array[1..100]of integer; Mat:vec; Sc:tab; n:integer; {**************************************************} procedure saisie ( n:integer); write('taper N:');readln(n); until (n in [5..100]); {**************************************************} procedure remplir ( mat:vec; sc: tab; n:integer); e,i:integer; X:longint; for i:=1 to n do write('mat[',i,']=');readln(mat[i]); val(mat[i],x,e); until (e=0)and (length(mat[i])=8); write('score de [',mat[i],']=');readln(sc[i]); until (sc[i] >=20)and(sc[i]<=120); {**************************************************} procedure tri ( mat:vec; sc:tab; n:integer); i:integer; echange:boolean; aux:star; aux2:integer; 1/8
echange:=false; for i:=1 to (n 1) do if (sc[i]<sc[i+1]) then aux:=mat[i]; mat[i]:=mat[i+1]; mat[i+1]:=aux; aux2:=sc[i]; sc[i]:=sc[i+1]; sc[i+1]:=aux2; echange:=true; until (echange=false); procedure afficher (mat:vec; n:integer); fin,i:integer; fin:=round(n*0.25); writeln('fin=',fin); write('liste des admis:'); for i:=1 to fin do write(mat[i],' '); BEGIN saisie(n); remplir(mat,sc,n); tri(mat,sc,n); afficher(mat,n); END. 2/8
Correction proposée par Mme Hajer NEFZAOUI Corrigés Bac pratique Informatique Section Math & Sciences & Technique 27 mai 2013(9h30) Lundi 27 mai 2013 à 9h30 program seance2; uses wincrt; type tab=array[1..20]of integer; t:tab; n:integer; {******************************************} procedure saisie ( n:integer); write('taper N: '); readln(n); until (N in [5..20]); {******************************************} procedure Remplir ( t:tab;n:integer); i:integer; for i:=1 to n do write('t[',i,']:'); readln(t[i]); until (T[i]>0); function chercher (t:tab; n:integer; x:integer):integer; p,i:integer; i:=1; p:=0; if T[i]=x then p:=i else i:=i+1; until (p>0)or (i>n); chercher:=p; {************************************************} Function verif (t:tab; n:integer):boolean; i,j,p:integer; rep:boolean; rep:=true; i:=0; Repeat i:=i+1; p:=chercher (t,n,i); 3/8
if((p=0) OR (p=i)) then rep:=false; Until (i=n) or(rep=false); verif:=rep; {******************************************} BEGIN END. saisie(n); remplir(t,n); if (verif(t,n)) then write('t est un dérangement ') else write(' t n''est pas un dérangement'); 4/8
Correction proposée par Mme Hajer NEFZAOUI Corrigés Bac pratique Informatique Section Math & Sciences & Technique 27 mai 2013(11h) Lundi 27 mai 2013 à 11h program seance3; uses wincrt; type tab=array [1..11] of longint; t:tab; n:longint; rep:boolean; {**********************************************} procedure saisie ( n:longint); write('taper n: '); readln(n); until ( N>=10); {**********************************************} function inverser (ch:string ): string; i:integer; chv:string; chv:=''; for i:=1 to length(ch) do chv:=ch[i]+chv; inverser:=chv; {**********************************************} function palindrome (ch:string):boolean; i:integer; i:=0; i:=i+1; until (ch[i]<>ch[length(ch) i+1])or (i=length(ch)); palindrome:=(i=length(ch)); {**********************************************} procedure traitement ( t:tab; n:longint); e,i:integer;ch,chv:string; m,x:longint; 5/8
rep:=false; for i:=1 to 11 do T[i]:=n; str(n,ch); chv:=inverser(ch); val(chv,m,e); X:=m+n; Str(x,chv); N:=X ; {************************************************} procedure afficher ( t:tab ); i:integer; ch:string; rep:boolean; rep:=false; for i:=1 to 11 do writeln('u',i,'=',t[i]); str(t[i],ch); if palindrome(ch) then rep:=true; if rep=true then write('cette suite est palindromique') else writeln('le calcul de 11 termes ne doonne pas une suite palindromique pou ce nombre '); { '} BEGIN SAISIE(n); traitement(t,n); afficher(t); END. 6/8
Correction proposée par Mme Hajer NEFZAOUI Corrigés Bac pratique Informatique Section Math & Sciences & Technique 27 mai 2013(14h) Lundi 27 mai 2013 à 14h program romains; uses wincrt; Const Xrt='MDCLXVI'; ch:string; {*************************************} Function verif ( ch:string):boolean; i:integer; rep:boolean; i:=1; rep:=true; if pos(ch[i],xrt)=0 then rep:=false else i:=i+1; until (rep=false) or (i>length(ch)); verif:=rep; {****************************} procedure saisie ( ch:string); write(' taper une chaine formée uniquement par des chiffres romains :'); readln(ch); until verif(ch)and(ch<>''); {*****************************} function decimal (c:char):integer; d:integer; case c of 'M': d:=1000; 'D': d:=500; 'C': d:=100; 'L': d:=50; 'X': d:=10; 'V': d:=5; 'I': d:=1; 7/8
decimal:=d; function equivalent (ch:string):integer; sig,s,d,i:integer; s:=0; sig:=1; for i:=1 to length(ch) 1 do d:=decimal(ch[i]); if (pos(ch[i],xrt)> pos(ch[i+1],xrt)) then sig:= 1 else sig:=1; S:=S+sig*d; S:=S+decimal(ch[length(ch)]); equivalent:=s; BEGIN saisie(ch); writeln(equivalent(ch)); END. 8/8