function totalnum(str1:string):integer;
  var
    i: integer;
    curnum,pronum:integer;
    tmpresult:integer;
  begin
    result:=0;
    tmpresult:=0;
    pronum:=-1;
    for i:=1 to length(str1) do
    begin
      curnum:=strtoint(str1[i]);
      if (curnum=pronum)  then
         result:= result +10;
      if (curnum=pronum+1)  then
         tmpresult:= tmpresult +10;
      pronum := curnum;
    end;
    if tmpresult =(length(str1)-1)*10 then
      result :=tmpresult;
  end;分数:= totalnum('1123660999');

解决方案 »

  1.   

    function totalnum(str1:string):integer;
      var
        i: integer;
        tmpresult:integer;
        tmpBoolean : Boolean 
      begin
        result:=0;
        tmpresult :=0;
        tmpBoolean := True; 
        for i:=1 to length(str1) do
          if str1[I-1] = Str1[I] then Inc(tmpResult,10);
        if tmpResult = 0 then
        for I:=1 to Length(Str1) do 
          if Ord(str1[I-1]) = Ord(Str1[I]) -1 then Inc(tmpResult,10);
        Result := tmpResult;
      end;分数:= totalnum('1123660999');
      

  2.   

    easy 循环两遍,就可以解决