procedure TForm1.ShareWatermelon(total, men: integer)
//total:西瓜数,men:人数
var
a: array[1..100] of integer;
I: integer;
S: string;
J: integer;
begin
S := '';
J := 0;
for I := 1 to men do
begin
a := (total + 1) div 2;
S := Format('第%d人分%d个西瓜',[I, a]);
ShowMessage(S);
J := Total - a;
Total := Total - J;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShareWaterMelon(StrToInt(Edit1.Text), StrToInt(Edit2.Text));
end;