about summary refs log tree commit diff
path: root/09/Q-Huế-2014/bai3.pas
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2017-01-09 10:47:37 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2017-01-09 10:47:37 +0700
commit318184dbda0658d8afae6dd3c13a0718382726a1 (patch)
tree5a62259a03200cd77823431994fe3479e5d7461f /09/Q-Huế-2014/bai3.pas
parent15b38076cc08d89024864252e99e10fe6f597196 (diff)
downloadcp-318184dbda0658d8afae6dd3c13a0718382726a1.tar.gz
Add NTU/{pali2,editpic}.c and update README.md
Diffstat (limited to '09/Q-Huế-2014/bai3.pas')
-rw-r--r--09/Q-Huế-2014/bai3.pas34
1 files changed, 34 insertions, 0 deletions
diff --git a/09/Q-Huế-2014/bai3.pas b/09/Q-Huế-2014/bai3.pas
new file mode 100644
index 0000000..91fc05f
--- /dev/null
+++ b/09/Q-Huế-2014/bai3.pas
@@ -0,0 +1,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.