pascal输入一数串,分割为两数串,依次累加,求最大和.

来源:百度知道 编辑:UC知道 时间:2024/06/15 13:42:33
pascal输入一数串,分割为两数串,依次累加,求最大和.
已知道答案,不过须大家解释一下

你说的是指分割成两个数串后的和的最大值么?
program ex;
var
a,b,c,d,max:longint;
begin
readln(a);
b:=10;{分割位置,从十位后开始}
max:=0;
repeat
c:=a div b;{取左段}
d:=a mod b;{取右段}
if c+d>max then max:=c+d;{统计最大值}
b:=b*10{枚举分割位置}
until a div b=0;{分割点到了最高位前即退出}
writeln(max);
end.

貌似这题要用高精度吧