var i: integer; c: string; begin i:=70; if i<60 then c:='c' else if (i>60) and (i<80) then c:='b' else if (i>80) and (i<100) then c:='a';showmessage( c ); end;--------------------------- Project1 --------------------------- b --------------------------- OK ---------------------------
function GetLevel(const fenshu:double):char; begin if (fenshu>=80) and (fenshu<=100) then begin result:='A'; end else if fenshu<60 then begin result:='C'; end else if(fenshu>=60) and (fenshu<=80) then begin result:='B'; end else begin Result:='X'; //分数>100 end; end;
确认了一下,确实没有elseif:) , 好久没有用了 -------------------- program Project1;{$APPTYPE CONSOLE}uses SysUtils;var x: integer; rank : string; begin { TODO -oUser -cConsole Main : Insert code here } x:= 20; if x > 80 then rank := 'A' else if x > 60 then rank := 'B' else rank := 'C';WriteLn(rank);read(rank); end.
i: integer;
c: string;
begin
i:=70;
if i<60 then c:='c'
else if (i>60) and (i<80) then c:='b'
else if (i>80) and (i<100) then c:='a';showmessage( c );
end;---------------------------
Project1
---------------------------
b
---------------------------
OK
---------------------------
begin
if (fenshu>=80) and (fenshu<=100) then
begin
result:='A';
end
else if fenshu<60 then
begin
result:='C';
end
else if(fenshu>=60) and (fenshu<=80) then
begin
result:='B';
end
else
begin
Result:='X'; //分数>100
end;
end;
--------------------
program Project1;{$APPTYPE CONSOLE}uses
SysUtils;var
x: integer;
rank : string;
begin
{ TODO -oUser -cConsole Main : Insert code here }
x:= 20; if x > 80 then
rank := 'A'
else
if x > 60 then
rank := 'B'
else
rank := 'C';WriteLn(rank);read(rank);
end.