回 帖 发 新 帖 刷新版面

主题:[原创]正确的应该怎么写?

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个回复)

沙发

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;

板凳

两个条件怎么不行?
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 楼

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 楼

我无法验正你的代码,但和下列的一样的,自己查查吧:
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 楼

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

我来回复

您尚未登录,请登录后再回复。点此登录或注册