Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // https://www.kiteb.net/education/informatique/bac/bacinfo2017/bac-pratique-27052017-algo-8h30.pdf
- program bac2017;
- uses WinCrt;
- type
- mat = array [1..20,1..10] of char;
- var
- m : mat;
- cle: string;
- g,f : Text;
- function verif(ch : string):Boolean;
- var
- a,b: integer ;
- vf : Boolean;
- begin
- a:=1 ;
- vf:=False;
- while (a <= Length(ch)) and (ch[a] in ['A'..'Z']) and (vf= false) do
- begin
- vf:=false;
- for b:=1 to Length(ch) do
- if (ch[a]= ch[b]) and (b<>a) then
- vf:=True;
- a:=a+1;
- end;
- verif:= a > Length(ch);
- end;
- Procedure saisi(var cle : string);
- begin
- Repeat
- write('ekteb el Clé= ');
- readln(cle);
- until(length(cle) in [5..10])and (verif(cle));
- end;
- Procedure init(var ch : String;cle: string);
- begin
- while (Length(ch) mod Length(cle) <> 0 ) do
- ch:=ch+' ';
- end;
- Procedure remp(var m : mat;ch, cle: string);
- var
- a,b : integer;
- Begin
- init(ch,cle);
- for a:=1 to Length(ch) div Length(cle) do
- begin
- for b:=1 to Length(cle) do
- m[a,b]:=ch[ b+(a-1)*Length(cle) ];
- end;
- {for a:=1 to Length(ch) div Length(cle) do
- begin
- for b:=1 to Length(cle) do
- write(m[a,b],' ');
- writeln;
- end; }
- end;
- Function boom(m : mat; ch,cle: string):string;
- var
- c : string;
- a,b : byte ;
- begin
- init(ch,cle);
- c:='';
- for b:=1 to Length(cle) do
- begin
- c:=c+cle[b];
- for a:=1 to Length(ch) div Length(cle) do
- c:=c+m[a,b]
- end;
- boom:=c;
- end;
- Procedure crypt(var f,g : text ; cle : string);
- var
- ch: string;
- begin
- rewrite(g);
- reset(f);
- while not (eof(f)) do
- begin
- readln(f,ch);
- remp(m,ch,cle);
- writeln(g,boom(m,ch,cle));
- end;
- close(f);
- close(g);
- end;
- Procedure aff(var g : text);
- var
- ch: String;
- begin
- reset(g);
- while not(eof(g)) do
- begin
- readln(g,ch);
- writeln(ch);
- End;
- close(g);
- end;
- begin
- assign(f,'C:\Users\platpot\Desktop\arfizato\progg\pascal\Projects\Source.txt');
- assign(g,'C:\Users\platpot\Desktop\arfizato\progg\pascal\Projects\Crypt.txt');
- saisi(cle);
- Crypt(f,g,cle);
- aff(g);
- end.
- {remp(m,'Les modifications de l''aspect',cle);
- write(boom(m,'Les modifications de l''aspect',cle));}
Add Comment
Please, Sign In to add comment