楚
楚辞
Unregistered / Unconfirmed
GUEST, unregistred user!
function TForm1.myround(source: string): string;var x: integer; gettail: string;begin if Int(StrToFloat(source)) < 1 then x := 7 else x := 6;//这是网友帮助写的,我不理解,取整<1,然后x:=7或者x:=6,给7,6于x, 是什么意思? result := IntToStr(Length(source)); case StrToInt(source[x]) of 6..9: source[x - 1] := IntToStr(StrToInt(source[x - 1]) + 1)[1]; 5: begin gettail := Copy(source, x + 1, Length(source) - x + 1); if StrToInt(gettail) > 0 then source[x - 1] := IntToStr(StrToInt(source[x - 1]) + 1)[1] else if StrToInt(source[x - 1]) mod 2 = 1 then source[x - 1] := IntToStr(StrToInt(source[x - 1]) + 1)[1]; end; end; result := Copy(source, 1, x - 1);