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
|
(* uuencoding *)
var
fi, fo: text;
s: string[45] = ' ';
n, i: shortint;
c1, c2, c3: byte;
begin
assign(fi, '1enc.inp');
reset(fi);
assign(fo, '1enc.out');
rewrite(fo);
repeat
n := 0;
while (n < 45) and not(eof(fi)) do
begin
inc(n);
read(fi, s[n])
end;
write(fo, chr(n + 32));
for i := 0 to n div 3 - 1 do
begin
c1 := ord(s[i * 3 + 1]);
c2 := ord(s[i * 3 + 2]);
c3 := ord(s[i * 3 + 3]);
write(fo, chr(c1 div 4 + 32));
write(fo, chr(c1 mod 4 * 16 + c2 div 16 + 32));
write(fo, chr(c2 mod 16 * 4 + c3 div 64 + 32));
write(fo, chr(c3 mod 64 + 32))
end;
if n mod 3 > 0 then
begin
c1 := ord(s[n div 3 * 3 + 1]);
if n mod 3 = 2 then
c2 := ord(s[n div 3 * 3 + 2])
else
c2 := 0;
c3 := 0;
write(fo, chr(c1 div 4 + 32));
write(fo, chr(c1 mod 4 * 16 + c2 div 16 + 32));
write(fo, chr(c2 mod 16 * 4 + c3 div 64 + 32));
writeln(fo, chr(c3 mod 64 + 32))
end
else
writeln(fo)
until eof(fi);
close(fi);
close(fo)
end.
|