procedure TForm1.Button1Click(Sender: TObject);
var
i:word;
begin
Ini;//初始化stringgrid1过程
with stringgrid1 do
for i:=1 to rowcount-1 do
if (strToInt(cells[1, i])+strToInt(cells[3, i]))>(strToInt(cells[2, i])+strToInt(cells[4, i])) then
cells[5,i]:= IntToStr((strToInt(cells[1, i])+strToInt(cells[3, i]))-(strToInt(cells[2, i])+strToInt(cells[4, i])))
else
cells[6,i]:= IntToStr((strToInt(cells[2, i])+strToInt(cells[4, i]))-(strToInt(cells[1, i])+strToInt(cells[3, i])));
end;