首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

20分求个DELPHI判断的代码解决思路

2012-03-17 
20分求个DELPHI判断的代码判断分数的多少给出等级!!!小于60,等级是C大于60并且小于80,等级是B大于80并且小

20分求个DELPHI判断的代码
判断分数的多少给出等级!!!

小于60,等级是C

大于60并且小于80,等级是B

大于80并且小于100,等级是A


我主要是不太清楚DELPHI中的   ELSEIF   的用法,以及   DELPHI   中有没有   AND   OR   及他们的用法

[解决办法]
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;

热点排行