diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-03-27 01:26:28 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2008-03-27 01:26:28 +0800 |
commit | b27ece46a69aa7d5b9a759a2164609dab689f258 (patch) | |
tree | ad7387b6b59ecfc3215deec393d1c932db8d09af /common/bbs/money.c | |
parent | 1ac9e4897fdf8839328d9c47d1d2f0cc27b02f1d (diff) | |
download | pttbbs-b27ece46a69aa7d5b9a759a2164609dab689f258.tar pttbbs-b27ece46a69aa7d5b9a759a2164609dab689f258.tar.gz pttbbs-b27ece46a69aa7d5b9a759a2164609dab689f258.tar.bz2 pttbbs-b27ece46a69aa7d5b9a759a2164609dab689f258.tar.lz pttbbs-b27ece46a69aa7d5b9a759a2164609dab689f258.tar.xz pttbbs-b27ece46a69aa7d5b9a759a2164609dab689f258.tar.zst pttbbs-b27ece46a69aa7d5b9a759a2164609dab689f258.zip |
(internal) refine directory layout: libbbs/libbbsutil -> common/bbs,sys.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4027 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'common/bbs/money.c')
-rw-r--r-- | common/bbs/money.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/common/bbs/money.c b/common/bbs/money.c new file mode 100644 index 00000000..f2c7b9b3 --- /dev/null +++ b/common/bbs/money.c @@ -0,0 +1,36 @@ +#include <stdio.h> +#include "cmbbs.h" + +/* 計算贈與稅 */ +int +give_tax(int money) +{ + int i, tax = 0; + int tax_bound[] = {1000000, 100000, 10000, 1000, 0}; + double tax_rate[] = {0.4, 0.3, 0.2, 0.1, 0.08}; + for (i = 0; i <= 4; i++) + if (money > tax_bound[i]) { + tax += (money - tax_bound[i]) * tax_rate[i]; + money -= (money - tax_bound[i]); + } + return (tax <= 0) ? 1 : tax; +} + +const char* +money_level(int money) +{ + int i = 0; + + static const char *money_msg[] = + { + "債台高築", "赤貧", "清寒", "普通", "小康", + "小富", "中富", "大富翁", "富可敵國", "比爾蓋\天", NULL + }; + while (money_msg[i] && money > 10) + i++, money /= 10; + + if(!money_msg[i]) + i--; + return money_msg[i]; +} + |