zoukankan      html  css  js  c++  java
  • 文本所有数字相加

    function GetNumSumFromStr(Str: string): Integer;
        function IsNumber(SoureChar: Char): Boolean;
        begin
          Result := False;
          if (Ord(SoureChar) >= 48) and (Ord(SoureChar) <= 57) then
            Result := True;
        end;

        function AddNum(SearthStr: string): string;
        var
          I: Integer;
        begin
          Result := '';
          I := 1;
          while(IsNumber(SearthStr[I]))do
          begin
           Result := Result + SearthStr[I];
           Inc(I);
          end;
        end;
    var
    I: Integer;
    Sum: Integer;
    Temp: string;
    begin
    Result := 0;
    I := 1 ;
    while I <= Length(Str) do
    begin
        if (i <> Length(Str)) and (IsNumber(str[i])) then
        begin
          Temp := AddNum(Copy(Str, I, Length(Str)));
          Result := Result + StrToInt(Temp);
          Inc(I, Length(Temp) + 1);
        end else
          Inc(i);
    end;
    end;

  • 相关阅读:
    日志模块
    模块介绍3
    模块介绍2
    模块介绍
    迭代器
    Python装饰器续/三元表达式/匿名函数
    Python装饰器详解
    LATEX LIAN XI
    BELLMAN 最短路算法
    B阿狸和桃子的游戏
  • 原文地址:https://www.cnblogs.com/chengxin1982/p/1359168.html
Copyright © 2011-2022 走看看