入题

解决方案 »

  1.   

    也没有什么好说的,找一段代码给你吧:
    转换中文数字
    //将指定数字转换成汉字的函数,UpperWord(源数字,是否货币汉字,是否自动加位数);
    function UpperWord(IDigital:integer;money:Boolean=false;AddBit:Boolean=false):string;
    var SDigital,sWord,SReturn:string;
        ITmp:integer;
    begin
      if Money then SWord:='零壹贰叁肆伍陆柒捌玖' else SWord:='零一二三四五六七八九';
      SDigital:=inttostr(IDigital);
      SReturn:='';
      ITmp:=Length(SDigital);
      while ITmp>0 do
      begin
        SReturn:=SReturn+copy(SWord,strtoint(copy(SDigital,1,1))*2+1,2);
        if AddBit then
        begin
          if copy(SDigital,1,1)='0' then
            if copy(SReturn,length(SReturn)-3,4)='零零' then  SReturn:=copy(SReturn,1,length(SReturn)-2);
            case ITmp of
            2,6,10:if copy(SDigital,1,1)<>'0' then SReturn:=SReturn+'十';
            3,7,11:if copy(SDigital,1,1)<>'0' then SReturn:=SReturn+'百';
            4,8,12:if copy(SDigital,1,1)<>'0' then SReturn:=SReturn+'千';
            5:if copy(SDigital,1,1)<>'0' then SReturn:=SReturn+'万' else (if  copy(SReturn,length(SReturn)-3,2)='亿' then SReturn:=copy(SReturn,1,length(SReturn)-2) else  SReturn:=copy(SReturn,1,length(SReturn)-2)+'万');
            9:if copy(SDigital,1,1)<>'0' then SReturn:=SReturn+'亿' else  SReturn:=copy(SReturn,1,length(SReturn)-2)+'亿';
            end;
        end;
        SDigital:=copy(SDigital,2,255);
        ITmp:=Length(SDigital);
      end;
      if AddBit then
        while copy(SReturn,length(SReturn)-1,2)='零' do
          SReturn:=copy(SReturn,1,length(SReturn)-2);
      UpperWord:=SReturn;
    end;
      

  2.   

    顶楼上  楼主注意看函数的介绍:UpperWord(源数字,是否货币汉字,是否自动加位数); 源数字即为你要转化的数字将此函数直接添加到你的代码里面 然后直接调用
      

  3.   

    function N2CH( strNum: String): String;
    const strCH : String = '零壹贰叁肆伍陸柒捌玖';
    var
      P_Num, P_CH: PChar;
      I: Integer;
    begin
      I := Length(strNum);
      SetString(Result,Nil, I * 2);
      P_Num := PChar(strNum);
      P_CH := PChar(Result);
      while I > 0 do begin
        Move(PChar(Integer(PChar(strCH)) + (Ord(P_Num^) - Ord('0')) * 2)^, P_CH^, 2);
        Inc(P_CH, 2);
        Inc(P_Num);
        Dec(I);
      end;
      P_Ch := Nil;
      P_Num := Nil;
    end;function I64toCH(I64Value: Int64): String;
    begin
      Result := N2CH(IntToStr(I64Value));
    end;
      

  4.   

    也给你一段吧!
    {将小写金额转换成大写金额
      金额最大位数不得超过15位(包括小数位)
      输入:inmoney-----小写金额,必须带小数点,且其后得带两位小数
      输出:outmoney----大写金额,长度最长为70位
      调用方式:ntoupper(char *inmoney, char *outmoney)
    }
    function ntoupper(inmoney:string):string;
    var
      outmoney:string;
      len, monlen:Integer;
      i:integer;
      buf:string;
    begin
    inmoney:=Trim(inmoney);
    if (inmoney= '0.00') or (inmoney='')  then
    begin
    outmoney:='零元整';
        Result:=outmoney;
    exit ;
      end;
    len := Length( inmoney );
    buf:=copy(inmoney, 1,len-3);  buf:=buf+copy(inmoney,len-1,2);
    len:=len-1;
    inmoney:=copy( buf, 1,len);
    monlen := len;
    for i:=1 to len do
      begin
    if (inmoney[i]<'0') or (inmoney[i]>'9') then
          continue;
    case inmoney[i] of
    '0':
            begin
      if  monlen=1 then
              begin
      monlen :=monlen-1;
      continue;
      end;
      if monlen=2 then
              begin
                if inmoney[i+1]<>'0'  then
                begin
            outmoney:=outmoney+ '零';
      end;
      monlen:=monlen -1;
      continue;
              end;
      if ( monlen<>11) and (monlen<>7) and (monlen<>3 ) then
              begin
        if inmoney[i+1]='0' then
                begin
        monlen:=monlen -1;
        continue;
        end;
          outmoney:=outmoney+'零';
        monlen :=monlen-1;
        continue;
        end
      else
              begin
                if monlen=3 then
                begin
        outmoney:=outmoney+'元';
        end;
        if  monlen=7 then
                begin
        outmoney:=outmoney+'万';
        end;
        if monlen=11 then
                begin
        outmoney:=outmoney+'亿';
        end;
        if (inmoney[i-1]='0') and (inmoney[i+1]<>'0') then
                begin
        outmoney:=outmoney+'零';
        end;
        monlen :=monlen-1;
        continue;
      end;
            end;
    '1':
         outmoney:=outmoney+'壹';
    '2':
      outmoney:=outmoney+'贰';
    '3':
            outmoney:=outmoney+'叁';
    '4':
         outmoney:=outmoney+'肆';
    '5':
            outmoney:=outmoney+'伍';
    '6':
            outmoney:=outmoney+'陆';
    '7':
            outmoney:=outmoney+'柒';
    '8':
            outmoney:=outmoney+'捌';
    '9':
            outmoney:=outmoney+'玖';
    end;
    case monlen of
    1:
    outmoney:=outmoney+'分';
    2:
            outmoney:=outmoney+'角';
    3:
            outmoney:=outmoney+'元';
    4:
            outmoney:=outmoney+'拾';
    5:
            outmoney:=outmoney+'佰';
    6:
            outmoney:=outmoney+'仟';
    7:
            outmoney:=outmoney+'万';
    8:
            outmoney:=outmoney+'拾';
    9:
            outmoney:=outmoney+'佰';
    10:
            outmoney:=outmoney+'仟';
    11:
            outmoney:=outmoney+'亿';
    12:
            outmoney:=outmoney+'拾';
    13:
            outmoney:=outmoney+'佰';
    14:
            outmoney:=outmoney+'仟';
    end;
    monlen:=monlen-1;
    end;
    if  inmoney[len-1] = '0' then
    outmoney:=outmoney+'整';
      Result:=outmoney;
    end;
      

  5.   

    function NumToUpper(inmoney:string):string;
    var
      outmoney:string;
      len, monlen:Integer;
      i:integer;
      buf:string;
    begin
        inmoney:=Trim(inmoney);
        if (inmoney= '0.00') or (inmoney='')  then
        begin
            outmoney:='零元整';
        Result:=outmoney;
            exit ;
      end;
        len := Length( inmoney );
        buf:=copy(inmoney, 1,len-3);  buf:=buf+copy(inmoney,len-1,2);
        len:=len-1;
        inmoney:=copy( buf, 1,len);
        monlen := len;
        for i:=1 to len do
      begin
            if (inmoney[i]<'0') or (inmoney[i]>'9') then
          continue;
            case inmoney[i] of
                '0':
            begin
                      if  monlen=1 then
              begin
                          monlen :=monlen-1;
                          continue;
                      end;
                      if monlen=2 then
              begin
                if inmoney[i+1]<>'0'  then
                begin
                           outmoney:=outmoney+ '零';
                          end;
                          monlen:=monlen -1;
                          continue;
              end;
                      if ( monlen<>11) and (monlen<>7) and (monlen<>3 ) then
              begin
                        if inmoney[i+1]='0' then
                begin
                            monlen:=monlen -1;
                            continue;
                        end;
                         outmoney:=outmoney+'零';
                        monlen :=monlen-1;
                        continue;
                    end
                      else
              begin
                if monlen=3 then
                begin
                            outmoney:=outmoney+'元';
                        end;
                        if  monlen=7 then
                begin
                            outmoney:=outmoney+'万';
                        end;
                        if monlen=11 then
                begin
                            outmoney:=outmoney+'亿';
                        end;
                        if (inmoney[i-1]='0') and (inmoney[i+1]<>'0') then
                begin
                            outmoney:=outmoney+'零';
                        end;
                        monlen :=monlen-1;
                        continue;
                      end;
            end;
                '1':
                outmoney:=outmoney+'壹';
                '2':
                  outmoney:=outmoney+'贰';
                '3':
            outmoney:=outmoney+'叁';
                    '4':
                outmoney:=outmoney+'肆';
                '5':
            outmoney:=outmoney+'伍';
                '6':
            outmoney:=outmoney+'陆';
                '7':
            outmoney:=outmoney+'柒';
                '8':
            outmoney:=outmoney+'捌';
                '9':
            outmoney:=outmoney+'玖';
            end;
            case monlen of
                1:
                    outmoney:=outmoney+'分';
                2:
            outmoney:=outmoney+'角';
                3:
            outmoney:=outmoney+'元';
                4:
            outmoney:=outmoney+'拾';
                5:
            outmoney:=outmoney+'佰';
                6:
            outmoney:=outmoney+'仟';
                7:
            outmoney:=outmoney+'万';
                8:
            outmoney:=outmoney+'拾';
                9:
            outmoney:=outmoney+'佰';
                10:
            outmoney:=outmoney+'仟';
                11:
            outmoney:=outmoney+'亿';
                12:
            outmoney:=outmoney+'拾';
                13:
            outmoney:=outmoney+'佰';
                14:
            outmoney:=outmoney+'仟';
            end;
            monlen:=monlen-1;
        end;
        if  inmoney[len-1] = '0' then
            outmoney:=outmoney+'整';
      Result:=outmoney;
    end;
      

  6.   

    贴个比较简单的function MoneyUpper(MoneyNum:string):string;
    var
      i:Integer;
      SingleMoney:string;
    begin
      for i:=1 to Length(MoneyNum) do
      begin
          case StrToInt(MoneyNum[i]) of
             0: SingleMoney:='零';
             1: SingleMoney:='壹';
             2: SingleMoney:='贰';
             3: SingleMoney:='叁';
             4: SingleMoney:='肆';
             5: SingleMoney:='伍';
             6: SingleMoney:='陆';
             7: SingleMoney:='柒';
             8: SingleMoney:='捌';
             9: SingleMoney:='玖';
          end;
          if Result='' then
              Result:=SingleMoney
          else
              Result:=Result+SingleMoney;
      end;end;
      

  7.   

    呵呵,多谢【unsigned】指教 小弟不才,以后多注意啦 o(∩_∩)o...
      

  8.   

    function UpperNumb(n:integer):widestring;
    const
      cUpper='零壹贰叁肆伍陸柒捌玖';
    var
      s:string;
      i,LenS:integer;
    begin
      s:=trim(str(n));
      LenS:=lengh(s);
      Result:='';
      for i:=1 to LenS do Result:=Result+cUpper[strtoint(s[i])+1];
    end;