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;

  • 相关阅读:
    整数的可除性
    椭圆曲线的基本概念
    数组方法分析-笔记
    JS-作用域
    JS-变量存储
    Web框架-inoic
    圣杯布局
    js,php中的面向对象
    正则
    math对象
  • 原文地址:https://www.cnblogs.com/chengxin1982/p/1359168.html
Copyright © 2011-2022 走看看