北大侠客行MUD论坛

 找回密码
 注册
搜索
热搜: 新手 wiki 升级
查看: 1329|回复: 0

【tintin++】中文数字转阿拉伯数字

[复制链接]
发表于 2023-9-18 13:59:37 | 显示全部楼层 |阅读模式
本帖最后由 edf 于 2023-9-18 02:02 PM 编辑
  1. #class texttofigur open;

  2. #var texttofigur_1 0;
  3. #var texttofigur_2 0;
  4. #function texttofigur {
  5.     #var texttofigur_1 = %1;
  6.     #var texttofigur_2 0;
  7.     #regexp $texttofigur_1 {九百} {#math texttofigur_2 $texttofigur_2+900;#REPLACE texttofigur_1 {九百} {}};
  8.     #regexp $texttofigur_1 {八百} {#math texttofigur_2 $texttofigur_2+800;#REPLACE texttofigur_1 {八百} {}};
  9.     #regexp $texttofigur_1 {七百} {#math texttofigur_2 $texttofigur_2+700;#REPLACE texttofigur_1 {七百} {}};
  10.     #regexp $texttofigur_1 {六百} {#math texttofigur_2 $texttofigur_2+600;#REPLACE texttofigur_1 {六百} {}};
  11.     #regexp $texttofigur_1 {五百} {#math texttofigur_2 $texttofigur_2+500;#REPLACE texttofigur_1 {五百} {}};
  12.     #regexp $texttofigur_1 {四百} {#math texttofigur_2 $texttofigur_2+400;#REPLACE texttofigur_1 {四百} {}};
  13.     #regexp $texttofigur_1 {三百} {#math texttofigur_2 $texttofigur_2+300;#REPLACE texttofigur_1 {三百} {}};
  14.     #regexp $texttofigur_1 {二百} {#math texttofigur_2 $texttofigur_2+200;#REPLACE texttofigur_1 {二百} {}};
  15.     #regexp $texttofigur_1 {一百} {#math texttofigur_2 $texttofigur_2+100;#REPLACE texttofigur_1 {一百} {}};
  16.     #regexp $texttofigur_1 {九十} {#math texttofigur_2 $texttofigur_2+90;#REPLACE texttofigur_1 {九十} {}};
  17.     #regexp $texttofigur_1 {八十} {#math texttofigur_2 $texttofigur_2+80;#REPLACE texttofigur_1 {八十} {}};
  18.     #regexp $texttofigur_1 {七十} {#math texttofigur_2 $texttofigur_2+70;#REPLACE texttofigur_1 {七十} {}};
  19.     #regexp $texttofigur_1 {六十} {#math texttofigur_2 $texttofigur_2+60;#REPLACE texttofigur_1 {六十} {}};
  20.     #regexp $texttofigur_1 {五十} {#math texttofigur_2 $texttofigur_2+50;#REPLACE texttofigur_1 {五十} {}};
  21.     #regexp $texttofigur_1 {四十} {#math texttofigur_2 $texttofigur_2+40;#REPLACE texttofigur_1 {四十} {}};
  22.     #regexp $texttofigur_1 {三十} {#math texttofigur_2 $texttofigur_2+30;#REPLACE texttofigur_1 {三十} {}};
  23.     #regexp $texttofigur_1 {二十} {#math texttofigur_2 $texttofigur_2+20;#REPLACE texttofigur_1 {二十} {}};
  24.     #regexp $texttofigur_1 {一十} {#math texttofigur_2 $texttofigur_2+10;#REPLACE texttofigur_1 {一十} {}};
  25.     #regexp $texttofigur_1 {十} {#math texttofigur_2 $texttofigur_2+10;#REPLACE texttofigur_1 {十} {}};
  26.     #regexp $texttofigur_1 {九} {#math texttofigur_2 $texttofigur_2+9;#REPLACE texttofigur_1 {九} {}};
  27.     #regexp $texttofigur_1 {八} {#math texttofigur_2 $texttofigur_2+8;#REPLACE texttofigur_1 {八} {}};
  28.     #regexp $texttofigur_1 {七} {#math texttofigur_2 $texttofigur_2+7;#REPLACE texttofigur_1 {七} {}};
  29.     #regexp $texttofigur_1 {六} {#math texttofigur_2 $texttofigur_2+6;#REPLACE texttofigur_1 {六} {}};
  30.     #regexp $texttofigur_1 {五} {#math texttofigur_2 $texttofigur_2+5;#REPLACE texttofigur_1 {五} {}};
  31.     #regexp $texttofigur_1 {四} {#math texttofigur_2 $texttofigur_2+4;#REPLACE texttofigur_1 {四} {}};
  32.     #regexp $texttofigur_1 {三} {#math texttofigur_2 $texttofigur_2+3;#REPLACE texttofigur_1 {三} {}};
  33.     #regexp $texttofigur_1 {二} {#math texttofigur_2 $texttofigur_2+2;#REPLACE texttofigur_1 {二} {}};
  34.     #regexp $texttofigur_1 {一} {#math texttofigur_2 $texttofigur_2+1;#REPLACE texttofigur_1 {一} {}};
  35.    

  36.     #nop 最低一件。
  37.     #if {"$texttofigur_2"=="0"} {#var texttofigur_2 1};
  38.     #RETURN {$texttofigur_2};
  39. }




  40. #class texttofigur close;
复制代码
转换范围是九百九十九以内,没有输入默认返回1
虽然是无意为之,但这个函数的好处是自动忽略“件”、“枚”之类的量词,只返回阿拉伯数字

应该有更好写法但我大脑过载懒得动了


北大侠客行Mud(pkuxkx.com),最好的中文Mud游戏!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|北大侠客行MUD ( 京ICP备16065414号-1 )

GMT+8, 2024-11-24 06:09 AM , Processed in 0.008617 second(s), 14 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表