标题: [格式转换] [开源] 数字转汉字拼读 NumcnV1.0 [打印本页]
作者: yang871674823 时间: 2012-7-24 23:06 标题: [开源] 数字转汉字拼读 NumcnV1.0
Number To Chinese v1.0
命令格式: Numcn [参数] [数字]
参数: -a 将数字转换为简写汉字
-b 将数字转换为大写汉字
(1)例如执行:复制代码
将会输出:复制代码
(2)例如执行:复制代码
将会输出:复制代码
注:数字为绝对值小于1x10^12的浮点型数字
本程序采用Pascal语言编写,代码开源,修改或传播请保留代码标识!
如果把结果想储存到变量里面:- @echo off
- ::转换参数
- set p=-a
-
- ::要转换的数字
- set num=10213.123
-
- for /f %%a in ('Numcn.exe %p% %num%') do set out=%%a
- echo %out%
-
- Pause
复制代码
没事搞着玩的,感觉实际用处不大
下载地址:http://bcn.bathome.net/s/tool/index.html?key=Numcn
Numcn.pas源代码:(Pascal)- Program Number_To_Chinese;
-
- // By:Yangyawei QQ:871674823
- // Bathmoe_ID: Yang871674823
- // 代码开源,修改或传播请保留此处!
-
- const w:array[1..4] of string =('',chr(58),chr(59),chr(60));
- m:array[1..3] of string =('',chr(61),chr(62));
- num:array[0..33] of string =('零','壹','贰','叁','肆','伍','陆','柒','捌','玖','拾','佰','仟','萬','億','點','負',
- '零','一','二','三','四','五','六','七','八','九','十','百','千','万','亿','点','负');
- var ch,a,b,c,tmp,ans :string;
- at: array[1..4] of char;
- cho :boolean;
- i,j,k,ef,t,chn :longint;
-
- begin
- if Paramstr(1)<>'' then begin
- cho:=true;
- if (Paramstr(1)='-a')or(Paramstr(1)='-A') then cho:=true;
- if (Paramstr(1)='-b')or(Paramstr(1)='-B') then cho:=false;
- ch:=Paramstr(2);
- a:=''; b:=''; c:='';
- if ch[1]='-' then begin
- a:=chr(64);
- delete(ch,1,1);
- end;
- while (ch[1]='0')and(ch[2]<>'.')and(ch<>'') do delete(ch,1,1);
- ef:=pos('.',ch);
- if ef<>0 then while ch[length(ch)]='0' do delete(ch,length(ch),1);
- ef:=pos('.',ch);
- if ef<>0 then begin
- c:=chr(63);
- for i:=ef+1 to length(ch) do
- c:=c+ch[i];
- end;
- if ef=0 then ef:=length(ch) else dec(ef);
- i:=ef;
- while i>0 do begin
- for j:=1 to 4 do at[j]:='-';
- tmp:='';
- for j:=1 to 4 do
- if (i-j+1<=ef)and(i-j+1>0) then at[j]:=ch[i-j+1];
- j:=1;
- while (j<=4)and(at[j]<>'-') do begin
- if at[j]<>'0' then
- tmp:=at[j]+w[j]+tmp;
- if at[j+1]='0' then tmp:='0'+tmp;
- inc(j);
- while at[j]='0' do inc(j);
- end;
- if tmp[length(tmp)]='0' then delete(tmp,length(tmp),1);
- i:=i-4;
- inc(t);
- if tmp<>'' then b:=tmp+m[t]+b else b:=tmp+b;
- end;
- if b='' then b:='0';
- ans:=a+b+c;
- if cho=true then chn:=31 else chn:=48;
- for i:=1 to length(ans) do write(num[ord(ans[i])-chn]);
-
- end else begin
- writeln;
- writeln('Number To Chinese v1.0':30);
- writeln('---------------------------------------');
- writeln(' 命令格式:Numcn [参数] [数字]');
- writeln('---------------------------------------');
- writeln(' 参数:':7,' -a 将数字转换为简写汉字':31);
- writeln(' ':8,'-b 将数字转换为大写汉字':30);
- writeln('---------------------------------------');
- writeln(' 例如执行:','Numcn -b 100123.9':25);
- writeln(' 将会输出:','壹拾萬零壹佰贰拾叁點玖':25);
- writeln('---------------------------------------');
- writeln(' 注:数字为绝对值小于1e12的浮点型数字');
- writeln('---------------------------------------');
- writeln('By:Yangyawei QQ:871674823':38);
- end;
- end.
复制代码
By:Yangyawei QQ:871674823
作者: sz1121 时间: 2012-7-25 12:20
支持楼主!
作者: yang871674823 时间: 2012-8-13 21:14
没人顶吗?
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |