当前位置:网站首页>Delphi Chinese digit to Arabic digit
Delphi Chinese digit to Arabic digit
2022-06-13 00:17:00 【csaaa2005】
Project use , I can't find it on the Internet , I wrote a
type
TChnnum=record
rate:integer;
str:string;
end;
const chndigit:array[0..9]of Char=(' zero ',' One ',' Two ',' 3、 ... and ',' Four ',' 5、 ... and ',' 6、 ... and ',' 7、 ... and ',' 8、 ... and ',' Nine ');
function TTabbedwithNavigationForm.ChnToNum (s:string):Integer;
var chnnums:array[0..3] of TChnnum ;
i,j:integer;
a,b,x:integer;
str:string ;
begin
chnnums[0].rate:=10;chnnums[0].str:=' Ten ';
chnnums[1].rate:=100;chnnums[1].str:=' hundred ';
chnnums[2].rate:=1000;chnnums[2].str:=' thousand ';
chnnums[3].rate:=10000;chnnums[3].str:=' ten thousand ';
// Align words from left
str:=s;
x:=0;
i:=0;
if str[1] =' Ten ' then begin
x:=10;
inc(i);
end;
while i<s.Length do
begin
a:=0;b:=1;
inc(i);
for j:=Low(chndigit) to High(chndigit) do
if str[i] =chndigit[j] then begin
if j=0 then inc(i)
else begin
a:=j;
break;
end;
end ;
if (a=0 ) and (i=1) then a:=1;
if i< s.Length then begin
inc(i);
for j:= Low(chnnums) to High(chnnums) do
if str[i]= chnnums[j].str then begin
b:= chnnums[j].rate;
break;
end;
end;
x:=x+a*b;
end;
Result:=x;
end;
边栏推荐
- What are the levels of safety accidents
- 浏览器缓存的执行流程
- Will PM (Project Manager) take the PMP Exam?
- Memory address mapping of u-boot
- March 11, 2022 diary: Mr. Wang's spring, strange template mode
- 机加工行业MES系统模具行业MES系统CNCl中工行业MES系统MES扫码报工MES数据采集
- [LeetCode]21. Merge two ordered linked lists twenty-nine
- On the usage details and special usage of switch case
- OSM map local publishing - how to generate vector maps of provinces and cities
- 3、 Storage system
猜你喜欢

Will PM (Project Manager) take the PMP Exam?

Interprocess communication - shared memory shmat

【HCIE论述】组播IGMP-A

Tsinghua Bosch joint ml center, thbi lab:cheng Yang Ying | realize safety reinforcement learning through the value at risk of constraints

KAUST:Deyao Zhu | 价值记忆图:基于离线强化学习的图结构世界模型

Is the PMP training organization an actual training?

Free lottery --- PMP renewal PDU | PMP knowledge map

OSM map local publishing - how to generate vector maps of provinces and cities

PMP test difficulty and pass rate

The origin of MySQL in bedtime stories
随机推荐
一篇文章学会子网划分
Day 3 of jsbom and DOM learning
[matlab] basic operation
Actual combat | UI automation test framework design and pageobject transformation
[LeetCode]7. Integer inversion thirty-nine
The whole process from entering URL to displaying page (interview)
Explain bio, NiO, AIO in detail
Learn to divide subnets in an article
How to control the display and hiding of layergroup through transparency in leaflet
Tsinghua-Bosch Joint ML Center, THBI Lab:Chengyang Ying | 通过约束条件风险价值实现安全强化学习
KAUST:Deyao Zhu | 价值记忆图:基于离线强化学习的图结构世界模型
Vscode实现PHP在浏览器实时预览
2022年3月11日记:王老师的春天,奇异的模板模式
Matlab【路径规划】—— 无人机药品配送路线最优化
Is the PMP training organization an actual training?
测试平台系列(97) 完善执行case部分
[matlab] polynomial calculation
[LeetCode]9. Palindromes thirty-two
SAP Business Technology Platform (BTP) workflow function introduction
How does the PMP handle the withdrawal?