about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--11/Q-2017/cau4.scm4
-rwxr-xr-x12/TP-HN-2008/R1/BL4.pas68
-rwxr-xr-xTHT/B/QG-2014/DIC.DAT1
-rw-r--r--[-rwxr-xr-x]THT/B/QG-2014/dic.pp0
-rwxr-xr-xothers/153x/060.py7
-rw-r--r--others/volume1/016.pas12
6 files changed, 62 insertions, 30 deletions
diff --git a/11/Q-2017/cau4.scm b/11/Q-2017/cau4.scm
index b9438f5..adf5fed 100644
--- a/11/Q-2017/cau4.scm
+++ b/11/Q-2017/cau4.scm
@@ -1,11 +1,11 @@
 (with-input-from-file "CAU4.INP" (lambda ()
   (with-output-to-file "CAU4.OUT" (lambda ()
     (define x (list->string (let read-string ((c (read-char)))
-      (if (or (eof-object? c) (char-ci=? c #\newline))
+      (if (or (eof-object? c) (char=? c #\newline))
           '()
           (cons c (read-string (read-char)))))))
     (let find-palin ((i 0))
-      (if ((lambda (s) (string-ci=? (string-reverse s) s))
+      (if ((lambda (s) (string=? (string-reverse s) s))
            (string-copy x i (string-length x)))
           (format #t "~a\n~a~a\n" i x (string-reverse (string-copy x 0 i)))
           (find-palin (+ i 1))))))))
diff --git a/12/TP-HN-2008/R1/BL4.pas b/12/TP-HN-2008/R1/BL4.pas
index 94dd3ba..c552b0d 100755
--- a/12/TP-HN-2008/R1/BL4.pas
+++ b/12/TP-HN-2008/R1/BL4.pas
@@ -1,26 +1,62 @@
 var
-  f : text;
-  n : word;
-  a, b : array of longword;
-  tmp0, tmp1 : longword;
+  f: text;
+  n, i: int16;
+  a, b: array of int32;
+
+
+procedure swp(var x, y: int32);
+  var
+    tmp: int32;
 
-procedure ins(var l : array of longword; x : longword);
   begin
-    setlength(l, length(l) + 1);
-    l[length(l) - 1] := x
+    tmp := x;
+    x := y;
+    y := tmp
   end;
 
+
+procedure qsort(l, h: int16);
+  var
+    i, j: int16;
+    tmp: int32;
+
+  begin
+    i := l;
+    j := h;
+    tmp := a[(l + h) div 2];
+
+    repeat
+      while a[i] < tmp do
+        inc(i);
+      while a[j] > tmp do
+        dec(j);
+
+      if i <= j then
+        begin
+          swp(a[i], a[j]);
+          swp(b[i], b[j]);
+          inc(i);
+          dec(j)
+        end;
+    until i > j;
+
+    if l < j then
+      qsort(l, j);
+    if i < h then
+      qsort(i, h)
+  end;
+
+
 begin
-  setlength(a, 0);
-  setlength(b, 0);
   assign(f, 'CLB.IN');
   reset(f);
   readln(f, n);
-  for i := 1 to n do
-    begin
-      readln(f, tmp0, tmp1);
-      ins(a, tmp0);
-      ins(b, tmp1)
-    end;
+  setlength(a, n);
+  setlength(b, n);
+  for i := 0 to n - 1 do
+    readln(f, a[i], b[i]);
   close(f);
-  
+  qsort(0, n - 1);
+  for i := 0 to n - 1 do
+    writeln(a[i], ' ', b[i])
+end.
diff --git a/THT/B/QG-2014/DIC.DAT b/THT/B/QG-2014/DIC.DAT
index bc5caec..af9c850 100755
--- a/THT/B/QG-2014/DIC.DAT
+++ b/THT/B/QG-2014/DIC.DAT
@@ -3,5 +3,6 @@ can
 mic
 man
 tiger
+tac
 hello
 world
diff --git a/THT/B/QG-2014/dic.pp b/THT/B/QG-2014/dic.pp
index 716249d..716249d 100755..100644
--- a/THT/B/QG-2014/dic.pp
+++ b/THT/B/QG-2014/dic.pp
diff --git a/others/153x/060.py b/others/153x/060.py
index bfbf0cc..66da821 100755
--- a/others/153x/060.py
+++ b/others/153x/060.py
@@ -2,10 +2,6 @@
 from fractions import Fraction
 
 
-def dec_div(n):
-    return n, l2, l5
-
-
 def decimal(fraction):
     a, b, l2, l5 = fraction.numerator, fraction.denominator, 0, 0
     if b == 1: return '{}\n'.format(a)
@@ -26,5 +22,4 @@ def decimal(fraction):
 
 
 with open('DECIMAL.INP') as fi, open('DECIMAL.OUT', 'w') as fo:
-    for line in fi:
-        fo.write(decimal(Fraction(*map(int, line.split()))))
+    for line in fi: fo.write(decimal(Fraction(*map(int, line.split()))))
diff --git a/others/volume1/016.pas b/others/volume1/016.pas
index e50eef0..510a029 100644
--- a/others/volume1/016.pas
+++ b/others/volume1/016.pas
@@ -11,12 +11,12 @@ begin
   repeat
     inc(i);
     while (j > 0) and
-    (k > 0) and
-    (s[i] > z[j]) do
-    begin
-      dec(j);
-      dec(k)
-    end;
+          (k > 0) and
+          (s[i] > z[j]) do
+      begin
+        dec(j);
+        dec(k)
+      end;
     inc(j);
     z[j] := s[i]
   until i = length(s);