zoukankan      html  css  js  c++  java
  • delphi小写金额转大写的函数《转》

    function NumToChar(const n: Real): string; //可以到万亿,并且可以随便扩大范围 
    const cNum: WideString = '零壹贰叁肆伍陆柒捌玖--万仟佰拾亿仟佰拾万仟佰拾元角分'; 
    cCha:array[0..1, 0..12]of string = (( '零元','零拾','零佰','零仟','零万','零亿','亿万','零零零','零零','零万','零亿','亿万','零元'), ( '','','','','','亿','亿','','','','亿','亿','')); 
    
    var i : Integer; 
    sNum,sTemp : WideString; 
    begin 
    result :=''; 
    sNum := format('%15d',[round(n * 100)]); 
    for i := 0 to 14 do 
    begin 
    stemp := copy(snum,i+1,1); 
    if stemp=' ' then continue 
    else result := result + cNum[strtoint(stemp)+1] + cNum[i+13]; 
    end; 
    for i:= 0 to 12 do 
    Result := StringReplace(Result, cCha[0,i], cCha[1,i], [rfReplaceAll]); 
    if pos('零分',result)=0 then 
    Result := StringReplace(Result, '零角', '', [rfReplaceAll]) 
    else Result := StringReplace(Result, '零角','', [rfReplaceAll]); 
    
    Result := StringReplace(Result, '零分','', [rfReplaceAll]); 
    end; 
    
    function Changdx2(mmje: Double): String; 
    const s1: String = '零壹贰叁肆伍陆柒捌玖'; 
    s2: String = '分角元拾佰仟万拾佰仟亿拾佰仟万'; 
    function StrTran(const S, S1, S2: String): String; 
    begin 
    Result := StringReplace(S, S1, S2, [rfReplaceAll]); 
    end; 
    var s, dx: String; 
    i, Len: Integer; 
    begin 
    if mmje < 0 then 
    begin 
    dx := ''; 
    mmje := -mmje; 
    end; 
    s := Format('%.0f', [mmje*100]); 
    Len := Length(s); 
    for i := 1 to Len do 
    dx := dx + Copy(s1, (Ord(s[i]) - Ord('0'))*2 + 1, 2) + Copy(s2, (Len - i)*2 + 1, 2); 
    dx := StrTran(StrTran(StrTran(StrTran(StrTran(dx, '零仟', ''), '零佰', ''), '零拾', ''), '零角', ''), '零分', ''); dx := StrTran(StrTran(StrTran(StrTran(StrTran(dx, '零零', ''), '零零', ''), '零亿', '亿'), '零万', ''), '零元', ''); if dx = '' then 
    Result := '零元整' 
    else Result := StrTran(StrTran(dx, '亿万', '亿零'), '零整', ''); 
    end;
  • 相关阅读:
    hdu 6702 ^&^ 位运算
    hdu 6709 Fishing Master 贪心
    hdu 6704 K-th occurrence 二分 ST表 后缀数组 主席树
    hdu 1423 Greatest Common Increasing Subsequence 最长公共上升子序列 LCIS
    hdu 5909 Tree Cutting FWT
    luogu P1588 丢失的牛 宽搜
    luogu P1003 铺地毯
    luogu P1104 生日
    luogu P1094 纪念品分组
    luogu P1093 奖学金
  • 原文地址:https://www.cnblogs.com/LceMeaning/p/3365394.html
Copyright © 2011-2022 走看看