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 /tht/B/QG-2014/dic.pp | |
parent | b2d80610db6beda38573890ed169815e495bc663 (diff) | |
download | cp-2f674dc80f0382f1c3178f435714960734dc9d3c.tar.gz |
Reorganize stuff from secondary school
Diffstat (limited to 'tht/B/QG-2014/dic.pp')
-rw-r--r-- | tht/B/QG-2014/dic.pp | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/tht/B/QG-2014/dic.pp b/tht/B/QG-2014/dic.pp deleted file mode 100644 index 716249d..0000000 --- a/tht/B/QG-2014/dic.pp +++ /dev/null @@ -1,96 +0,0 @@ -unit dic; -interface - function count_char(c: char): longint; - function get_char_at_pos(x: longint): char; - procedure answer(s: string); - -implementation -var - secret_word: string; - words: array [1..1000000] of string; - total_cost, n: longint; - -procedure answer(s: string); -begin - if s = secret_word then - begin - writeln('Chuc mung ban da tim ra dap an chinh xac la "', s, '"'); - writeln('Chi phi ban da su dung la ', total_cost); - end - else - begin - writeln('Dap an ban dua ra la "', s, '"'); - writeln('Dap an chinh xac la "', secret_word, '"'); - end; - halt; -end; - -procedure cost_limit_exceed; -begin - writeln('Chi phi ban da su dung vuot qua chi phi toi da cho phep'); - halt; -end; - -function count_char(c: char): longint; -var - i, res: longint; -begin - total_cost := total_cost + 1; - if (total_cost > 1000) then - cost_limit_exceed; - res := 0; - for i := 1 to length(secret_word) do - if secret_word[i] = c then - inc(res); - exit(res); -end; - -function get_char_at_pos(x: longint): char; -begin - total_cost := total_cost + 10; - if (total_cost > 1000) then - cost_limit_exceed; - if (x < 1) or (x > length(secret_word)) then - exit('#'); - exit(secret_word[x]); -end; - -procedure check_secret_word; -var - f: text; - i: longint; - ok: boolean; -begin - assign(f, 'DIC.DAT'); - reset(f); - while not seekeof(f) do - begin - inc(n); - readln(f, words[n]); - end; - close(f); - ok := false; - for i := 1 to n do - if words[i] = secret_word then ok := true; - if not ok then - begin - writeln('Du lieu duoc khoi tao khong chinh xac. Dap an can tim khong nam trong tu dien'); - halt; - end; -end; - -procedure init; -begin - writeln; - writeln(' TU DIEN '); - writeln('*****************'); - writeln; - - secret_word := 'cat'; - total_cost := 0; - check_secret_word; -end; - -initialization - init; -end. |