主题:[原创]正确的应该怎么写?
freewolf
[专家分:30] 发布于 2006-07-18 22:06:00
begin
if A > 0 and B > 0 then
y:=1;
if A > 0 and B < 0 then
y:=2;
if A < 0 and B < 0 then
y:=3;
else
y:=4;
end;
回复列表 (共5个回复)
沙发
freewolf [专家分:30] 发布于 2006-07-18 22:25:00
begin
if A > 0 and B > 0 then
y:=1;
else if A > 0 and B < 0 then
y:=2;
else if A < 0 and B < 0 then
y:=3;
else if a < 0 and B > 0 then
y:=4;
end;
板凳
freewolf [专家分:30] 发布于 2006-07-18 22:55:00
两个条件怎么不行?
begin
if (A > 0) and (B > 0) then
y:=1;
else if (A > 0) and (B < 0) then
y:=2;
else if (A < 0 )and (B < 0) then
y:=3;
else if (a < 0) and (B > 0) then
y:=4;
end;
错在哪儿啊,急啊,有哪位兄弟帮忙解释下?
3 楼
freewolf [专家分:30] 发布于 2006-07-19 10:07:00
begin
if (A > 0) and (B > 0) then
y:=1
else if (A > 0) and (B < 0) then
y:=2
else if (A < 0 )and (B < 0) then
y:=3
else if (a < 0) and (B > 0) then
y:=4;
end;
4 楼
wealthy [专家分:1840] 发布于 2006-07-19 11:21:00
我无法验正你的代码,但和下列的一样的,自己查查吧:
procedure TForm1.Button1Click(Sender: TObject);
var
a,b,y:integer;
begin
if (edit2.Text > IntToStr(0)) and (edit3.Text > IntToStr(0)) then
begin
y:=1;
edit1.Text:=IntToStr(y); end
else
if (edit2.Text > IntToStr(0)) and (edit3.Text < IntToStr(0)) then
begin
y:=2;
edit1.Text:=IntToStr(y); end
else if (edit2.Text < IntToStr(0)) and (edit3.Text < IntToStr(0)) then
begin
y:=3;
edit1.Text:=IntToStr(y); end
else if (edit2.Text < IntToStr(0)) and (edit3.Text > IntToStr(0)) then
begin
y:=4;
edit1.Text:=IntToStr(y); end
end;
5 楼
MartinXiao [专家分:30] 发布于 2006-07-19 15:02:00
if A >0 then
begin
if b >0 then y := 1;
else if b<0 then y := 2;
end
else if A<0 then
begin
if b >0 then y := 4;
else if b<0 then y := 3;
end
我来回复