procedure TForm1.FormCreate(Sender: TObject);
var
s1,s2,s3,s4,s5,s6:integer;
begin
s1:=0;
s2:=0;
s3:=0;
s4:=0;
s5:=0;
s6:=0;
label1.Caption :=inttostr(s1);
label2.Caption :=inttostr(s2);
label3.Caption :=inttostr(s3);
label4.Caption :=inttostr(s4);
label5.Caption :=inttostr(s5);
label6.Caption :=inttostr(s6);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
max,flag:integer;
begin
max:=s1;
flag:=1;
if(s2>max)then
begin
max:=s2;
flag:=2;
end
else if9s3>max)then
begin
max:=s3;
flag:=3;
end
else if9s4>max)then
begin
max:=s4;
flag:=4;
end
else if(s5>max)then
begin
max:=s5;
flag:=5;
end
else if(s6>max)then
begin
max:=s6;
flag:=6;
end;
case flag of
1:showmessage('最优秀的人是小明,得票数为'+inttostr(max));
2:showmessage('最优秀的人是小龙,得票数为'+inttostr(max));
3:showmessage('最优秀的人是小东,得票数为'+inttostr(max));
4:showmessage('最优秀的人是小化,得票数为'+inttostr(max));
5:showmessage('最优秀的人是小武,得票数为'+inttostr(max));
6:showmessage('最优秀的人是小双,得票数为'+inttostr(max));
end;
end;
错在哪儿?
procedure TForm1.Button2Click(Sender: TObject);
var
i:integer;
begin
try
i:=strtoint(edit1.text);
if((i>6)or(i<1))then
showmessage('请输入1-6之间的数字');
case i of
1:s1:=s1+1;
2:s2:=s2+1;
3:s3:=s3+1;
4:s4:=s4+1;
5:s5:=s5+1;
6:s6:=s6+1;
except
on econverterror do
showmessage('请输入正确的数字');
end;
end;
end.