Arfizato

professional xd

Jun 25th, 2020
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.50 KB | None | 0 0
  1. // https://www.kiteb.net/education/informatique/bac/bacinfo2017/bac-pratique-27052017-algo-8h30.pdf
  2. program bac2017;
  3. uses WinCrt;
  4. type
  5. mat = array [1..20,1..10] of char;
  6. var
  7. m : mat;
  8. cle: string;
  9. g,f : Text;
  10. function verif(ch : string):Boolean;
  11.     var
  12.         a,b: integer ;
  13.         vf : Boolean;
  14.     begin
  15.         a:=1    ;
  16.         vf:=False;
  17.         while (a <= Length(ch)) and (ch[a] in ['A'..'Z']) and (vf= false) do
  18.             begin
  19.                 vf:=false;
  20.                 for b:=1 to Length(ch) do
  21.                     if (ch[a]= ch[b]) and (b<>a) then
  22.                         vf:=True;
  23.                 a:=a+1;
  24.             end;   
  25.         verif:= a > Length(ch);
  26.     end;
  27.    
  28.     Procedure saisi(var cle : string);
  29.      begin
  30.         Repeat
  31.             write('ekteb el Clé= ');
  32.              readln(cle);
  33.         until(length(cle) in [5..10])and (verif(cle));
  34.      end;
  35.      
  36.      Procedure init(var ch : String;cle: string);
  37.         begin
  38.             while (Length(ch) mod Length(cle) <> 0 ) do
  39.                 ch:=ch+' ';
  40.          end;
  41.          
  42.          Procedure remp(var m : mat;ch, cle: string);
  43.             var
  44.                  a,b : integer;
  45.             Begin
  46.                     init(ch,cle);
  47.                  for a:=1 to Length(ch) div Length(cle) do
  48.                     begin                          
  49.                         for b:=1 to Length(cle) do
  50.                             m[a,b]:=ch[ b+(a-1)*Length(cle) ];
  51.                     end;
  52.                     {for a:=1 to Length(ch) div Length(cle) do
  53.                     begin
  54.                         for b:=1 to Length(cle) do
  55.                             write(m[a,b],'  ');
  56.                         writeln;
  57.                     end; }
  58.             end;
  59.             Function boom(m : mat; ch,cle: string):string;
  60.                 var
  61.                     c : string;
  62.                     a,b : byte ;
  63.                 begin
  64.                     init(ch,cle);
  65.                     c:='';
  66.                     for b:=1 to Length(cle) do
  67.                         begin
  68.                          c:=c+cle[b];
  69.                          for a:=1 to  Length(ch) div Length(cle) do
  70.                             c:=c+m[a,b]    
  71.                                                                                
  72.                         end;
  73.                     boom:=c;
  74.                 end;   
  75.          
  76.                  Procedure crypt(var f,g : text ; cle : string);
  77.                      var
  78.                         ch: string;
  79.                      begin
  80.                         rewrite(g);
  81.                         reset(f);
  82.                             while not (eof(f)) do
  83.                                 begin
  84.                                     readln(f,ch);
  85.                                     remp(m,ch,cle);
  86.                                     writeln(g,boom(m,ch,cle));
  87.                                 end;
  88.                         close(f);
  89.                         close(g);
  90.                      end;
  91.                      Procedure aff(var g : text);
  92.                         var
  93.                             ch: String;
  94.                         begin
  95.                             reset(g);
  96.                                 while not(eof(g)) do
  97.                                     begin
  98.                                         readln(g,ch);
  99.                                         writeln(ch);
  100.                                     End;
  101.                             close(g);
  102.                         end;   
  103. begin
  104. assign(f,'C:\Users\platpot\Desktop\arfizato\progg\pascal\Projects\Source.txt');
  105. assign(g,'C:\Users\platpot\Desktop\arfizato\progg\pascal\Projects\Crypt.txt');
  106.     saisi(cle);
  107.    
  108.     Crypt(f,g,cle);
  109.     aff(g);
  110. end.
  111.  
  112. {remp(m,'Les modifications de l''aspect',cle);
  113.  
  114.     write(boom(m,'Les modifications de l''aspect',cle));}
Add Comment
Please, Sign In to add comment