Advertisement
LOVEGUN

Bac 2014 (Problème sans le remplissage du fichier)

Feb 14th, 2021
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.30 KB | None | 0 0
  1. Program bac2014;
  2. Uses Wincrt;
  3. Type
  4.   tab = Array [0..10,0..10] Of Integer;
  5.   tib = Array [1..9] Of Integer;
  6. Var
  7.   f: Text;
  8.   t,t2: tab;
  9. Procedure creation (Var f:Text);
  10. Begin
  11.   Assign (f,'c:\bac\Matrice_aléatoire.txt');
  12. End;
  13. Procedure remplir (Var f:Text;Var t:tab);
  14. Var
  15.   i,j: Integer;
  16. Begin
  17.   Reset (f);
  18.   For i:=1 To 5 Do
  19.     For j:=1 To 6 Do
  20.       Readln (f,t[i,j]);
  21.   Close (f);
  22. End;
  23. Procedure tri_bulle (Var t3:tib;n:Integer);
  24. Var
  25. i,aux:integer;
  26. Begin
  27.   Repeat
  28.     For i:=1 To n-1 Do
  29.       If t3[i]<t3[i+1] Then
  30.         Begin
  31.           aux := t3[i];
  32.           t3[i] := t3[i+1];
  33.           t3[i+1] := aux;
  34.         End;
  35.     n := n-1;
  36.   Until n=0;
  37. End;
  38.  
  39. Procedure decomp (t:tab;n,m:Integer;Var t3:tib);
  40. Var
  41.   i,j,x: Integer;
  42. Begin
  43.   x := 0;
  44.   For i:=n-1 To n+1 Do
  45.     For j:=m-1 To m+1 Do
  46.       Begin
  47.         x := x+1;
  48.         t3[x] := t[i,j];
  49.       End;
  50. End;
  51. Procedure traitement (t:tab;Var t2:tab);
  52. Var
  53.   i,j: Integer;
  54.   t3: tib;
  55. Begin
  56.   For i:=1 To 5 Do
  57.     For j:=1 To 6 Do
  58.       Begin
  59.         decomp (t,i,j,t3);
  60.         tri_bulle (t3,9);
  61.         t2[i,j] := t3[5];
  62.       End;
  63.   For i:=1 To 5 Do
  64.     Begin
  65.       Writeln;
  66.       For j:=1 To 6 Do
  67.         Write (t2[i,j],' | ');
  68.     End;
  69. End;
  70. Begin
  71.   creation (f);
  72.   remplir (f,t);
  73.   traitement(t,t2);
  74. End.
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement