1
0
Fork 0
This commit is contained in:
Nguyễn Gia Phong 2017-06-27 19:43:53 +07:00
parent 91b5248c8b
commit 6f155876ee
6 changed files with 62 additions and 30 deletions

View File

@ -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))))))))

View File

@ -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.

View File

@ -3,5 +3,6 @@ can
mic
man
tiger
tac
hello
world

0
THT/B/QG-2014/dic.pp Executable file → Normal file
View File

View File

@ -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()))))

View File

@ -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);