1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
| program crypto;
uses crt;
const fin=26;
maxlettre='Z';
type tabori=array[1..fin] of char;
tabin=array[1..fin] of char;
tabres=array[1..fin] of char;
tabcomb=array[1..fin] of char;
tabcode=array[1..fin] of string;
var a:tabori;
b:tabin;
c:tabres;
p:tabcomb;
nomcode:tabcode;
lettre,reponse:char;
i,j:integer;
BEGIN
for lettre:='A' to maxlettre do
begin
i:=1;
a[i]:=lettre;
inc(i,1);
end;
writeln('Tableau alphabetique initial');
for i:=1 to fin do
begin
writeln(a[i]);
end;
for i:=1 to fin do
begin
IF odd(i) THEN b[i]:='I'
ELSE b[i]:='O';
end;
for i:=1 to fin do
begin
writeln(b[i]);
end;
for i:=1 to fin do
begin
IF odd(i) THEN c[i]:=a[i+1]
ELSE c[i]:=a[i];
end;
for i:=1 to fin do
begin
writeln(c[i]);
end;
writeln('Codons le mot que vous souhaitez');
writeln('Entrez lettre par lettre le mot en question:');
for j:=1 to fin do
begin
writeln('Entrez la',j,'-ieme lettre du mot:');
readln(reponse);
p[j]:=reponse;
begin
a[1]:='A'; a[fin]:='Z';
while (p[j]<>a[1] )AND (p[j]<>a[fin]) do
IF p[j]>a[j] THEN
REPEAT
a[j-1]:=a[j]
UNTIL p[j]=a[j]
ELSE
REPEAT
a[j+1]:=a[j];
UNTIL p[j]=a[j];
IF p[j]=a[1] THEN a[j]:='A'
ELSE a[j]:='Z';
end;
end;
for j:=1 to fin do
writeln(p[j]);
writeln;
for j:=1 to fin do
writeln('Ainsi, au rang',j,'les tableaux p et a correspondent');
writeln;
for j:=1 to fin do
begin
IF odd(j) THEN nomcode[j]:=c[j]
ELSE nomcode[j]:='sym';
end;
writeln;
for j:=1 to fin do
writeln('Voici le mot apres chiffrage:');
writeln('<');
write(nomcode[j]);
writeln('>');
readln;
END. |
Partager