Advertisement
LOVEGUN

Bac 2011 (Problème)

Feb 6th, 2021
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.78 KB | None | 0 0
  1. Program probleme2011;
  2. Uses Wincrt;
  3. Type
  4.   mat = Array [1..50,1..50] Of Integer;
  5. Var
  6.   f1,f2: Text;
  7.   m: mat;
  8. Procedure creation (Var f1,f2:Text);
  9. Begin
  10.   Assign(f1,'C:\bac\TxtInit.txt');
  11.   Assign(f2,'C:\bac\TxtCryp.txt');
  12. End;
  13. Function long (Var f1:Text): Integer;
  14. Var
  15.   x: Integer;
  16.   ch: String;
  17. Begin
  18.   Reset (f1);
  19.   Readln (f1,ch);
  20.   x := Length(ch);
  21.   While Not (Eof(f1)) Do
  22.     Begin
  23.       Readln (f1,ch);
  24.       If (Length(ch)>x) Then
  25.         x := Length(ch);
  26.     End;
  27.   long := x;
  28.   Close (f1);
  29. End;
  30. Function convert (n:Integer): String;
  31. Var
  32.   x,x1,e: Integer;
  33.   ch1,ch: String;
  34. Function invers (ch:String): String;
  35. Var
  36.   i: Integer;
  37.   ch1: String;
  38. Begin
  39.   ch1 := '';
  40.   For i:=Length(ch) Downto 1 Do
  41.     ch1 := ch1+ch[i];
  42.   invers := ch1;
  43. End;
  44. Begin
  45.   ch := '';
  46.   Repeat
  47.     Str (n Mod 8,ch1);
  48.     ch := ch+ch1;
  49.     n := n Div 8;
  50.   Until (n Mod 8=0) And (n=0);
  51.   convert := invers(ch);
  52. End;
  53. Procedure traitement (Var f1,f2:Text;Var m:mat);
  54. Var
  55.   long_max: Integer;
  56.   i,j,l: Integer;
  57.   ch: String;
  58. Begin
  59.   long_max := long(f1);
  60.   Reset (f1);
  61.   i := 0;
  62.   While Not (Eof(f1)) Do
  63.     Begin
  64.       i := i+1;
  65.       Readln (f1,ch);
  66.       For j:=1 To long_max Do
  67.         If j<=Length(ch) Then
  68.           m[i,j] := Ord(ch[j])
  69.         Else
  70.           m[i,j] := Ord(' ');
  71.     End;
  72.   Close (f1);
  73.   l := i;
  74.   Rewrite (f2);
  75.   For j:=1 To long_max Do
  76.     Begin
  77.       If j<>1 Then Writeln (f2);
  78.       For i:=1 To l Do
  79.         Write (f2,convert(m[i,j]),' ');
  80.     End;
  81.   Close (f2);
  82. End;
  83. Procedure affiche (Var f2:Text);
  84. Var
  85.   ch: String;
  86. Begin
  87.   Reset (f2);
  88.   While Not (Eof(f2)) Do
  89.     Begin
  90.       Readln (f2,ch);
  91.       Writeln (ch);
  92.     End;
  93.   Close (f2);
  94. End;
  95. Begin
  96.   creation (f1,f2);
  97.   traitement (f1,f2,m);
  98.   affiche (f2);
  99. End.
  100.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement