判断分数的多少给出等级!!!小于60,等级是C大于60并且小于80,等级是B大于80并且小于100,等级是A我主要是不太清楚DELPHI中的 ELSEIF 的用法,以及 DELPHI 中有没有 AND OR 及他们的用法

解决方案 »

  1.   

    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   
    ---------------------------
      

  2.   

    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;
      

  3.   

    确认了一下,确实没有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.