diff options
author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2020-06-06 21:33:13 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2020-06-06 21:33:13 +0700 |
commit | 2f674dc80f0382f1c3178f435714960734dc9d3c (patch) | |
tree | 2abba7e4ec72bd16f58f7375126144d3fd9f4bca /2ndary/12/TP-ThanhHoá-2009/bai3.pas | |
parent | b2d80610db6beda38573890ed169815e495bc663 (diff) | |
download | cp-2f674dc80f0382f1c3178f435714960734dc9d3c.tar.gz |
Reorganize stuff from secondary school
Diffstat (limited to '2ndary/12/TP-ThanhHoá-2009/bai3.pas')
-rw-r--r-- | 2ndary/12/TP-ThanhHoá-2009/bai3.pas | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/2ndary/12/TP-ThanhHoá-2009/bai3.pas b/2ndary/12/TP-ThanhHoá-2009/bai3.pas new file mode 100644 index 0000000..a98141e --- /dev/null +++ b/2ndary/12/TP-ThanhHoá-2009/bai3.pas @@ -0,0 +1,44 @@ +var + f: text; + s: string; + min: byte = 255; + + +procedure palen( + s: string; + tmp: smallint +); + + begin + if tmp + length(s) >= min then + exit; + + if length(s) < 2 then + begin + min := tmp + length(s); + exit + end; + + if s[1] = s[length(s)] then + palen(copy(s, 2, length(s) - 2), tmp + 2) + else + begin + palen(copy(s, 2, length(s) - 1), tmp + 2); + palen(copy(s, 1, length(s) - 1), tmp + 2) + end + end; + + +begin + assign(f, 'BAI3.INP'); + reset(f); + read(f, s); + close(f); + + palen(s, -length(s)); + + assign(f, 'BAI3.OUT'); + rewrite(f); + writeln(f, min); + close(f) +end. |