Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

vendredi 24 avril 2020

Baccalauréat 2014 SI Sujet 2 Corrigé

Program S2; Type Mat = array[1..19,1..19] Of integer; Var M : Mat; n : integer; f : text; //******************************* Function premier(x:integer) : boolean; Var i,nb : integer; Begin nb := 0; For i:=1 To x Do If x Mod i=0 Then nb := nb+1; premier := nb=2; End; //******************************* Procedure Remplir(Var M:Mat;n:integer); Var i,j,x,y : integer; Begin For i:=1 To n Do For j:=1 To n Do Repeat write('M[',i,',',j,']='); readln(M[i,j]); Until premier(M[i,j]); End; //******************************* Procedure Creer(Var F:text;T:Mat;n:Integer); Var i,j,nb : integer; x,ch,ind : String; Begin rewrite(F); nb := 0; For i:=1 To n Do Begin str(i,ind); ch := 'L'+ind+'*'; nb := 0; For j:=1 To n-1 Do If T[i][j]<T[i][j+1] Then Begin str(T[i][j],x); nb := nb+1; ch := ch+x+'-'; End; If nb=n-1 Then Begin str(T[i][j+1],x); ch := ch+x; WriteLn(F,ch); End; End; nb := 0; For i:=1 To n Do Begin str(i,ind); ch := 'L'+ind+'*'; nb := 0; For j:=1 To n-1 Do If T[i][j]>T[i][j+1] Then Begin str(T[i][j],x); nb := nb+1; ch := ch+x+'-'; End; If nb=n-1 Then Begin str(T[i][j+1],x); ch := ch+x; WriteLn(F,ch); End; End; nb := 0; For j:=1 To n Do Begin str(j,ind); ch := 'C'+ind+'*'; nb := 0; For i:=1 To n-1 Do If T[i][j]<T[i+1][j] Then Begin str(T[i][j],x); nb := nb+1; ch := ch+x+'-'; End; If nb=n-1 Then Begin str(T[i+1][j],x); ch := ch+x; WriteLn(F,ch); End; End; nb := 0; For j:=1 To n Do Begin str(j,ind); ch := 'C'+ind+'*'; nb := 0; For i:=1 To n-1 Do If T[i][j]>T[i+1][j] Then Begin str(T[i][j],x); nb := nb+1; ch := ch+x+'-'; End; If nb=n-1 Then Begin str(T[i+1][j],x); ch := ch+x; WriteLn(F,ch); End; End; close(F); End; //******************************* Procedure Affiche(Var F:Text); Var ch : string; Begin reset(F); While Not eof(F) Do Begin readln(F,ch); writeln(ch); End; close(F); End; //******************************* Procedure saisie(Var n:integer); Begin Repeat write('n:'); readln(n); Until (n In [5..19]); End; //******************************* Begin assign(F,'c:\bac2014\Result.txt'); rewrite(F); saisie(n); Remplir(M,n); Creer(F,M,n); Affiche(F); End.
 
Back to top