about summary refs log tree commit diff
path: root/9/Q-Huế-2014/bai3.pas
blob: 91fc05f3a7430e0f3412914c4407769c1c0dbb67 (plain) (blame)
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
var
  x, y: string;
  f: text;
  a: array[0 .. 9] of shortint;
  b: shortint;
  c: char;

begin
  assign(f, 'INPUT.INP');
  reset(f);
  readln(f, x);
  readln(f, y);
  close(f);

  fillchar(a, 0, sizeof(a));

  for c in x do
    a[ord(c) - 48] := 1;

  for c in y do
    begin
      b := ord(c) - 48;
      if a[b] = 1 then
        a[b] := 2
    end;

  assign(f, 'OUTPUT.OUT');
  rewrite(f);
  for b := 9 downto 0 do
    if a[b] = 2 then
      write(f, b);
  writeln(f);
  close(f)
end.