1 条题解

  • 0
    @ 2025-2-14 20:39:29

    C :

    int main(int argc, const char * argv[]) {
        int score[100];
        int i;
        int countA = 0;
        int countB = 0;
        int countC = 0;
        int countD = 0;
        for (i = 0; i < 100; i++) {
        //    scanf("%d",&score[i]);
            score[i] = -1;
        }
        for (i = 0; i < 100; i++) {
            scanf("%d",&score[i]);
        }
        i = 0;
        while (score[i] != -1) {
            if ((score[i]>=85) && (score[i]<=100)) 
                countA ++;
            else if ((score[i]>=75) && (score[i]<=84))
                countB ++;
            else if ((score[i]>=60) && (score[i]<=74))
                countC ++;
            else
                countD ++;
              i++;
        }
        
    
        printf("A:%d\nB:%d\nC:%d\nD:%d\n",countA,countB,countC,countD);
    }
    

    Pascal :

    program bhfd;
    var
      a:array[1..101] of integer;
      i,j,n,b,c,d,e:integer;
    begin
      for i:=1 to 101 do
      a[i]:=0;
      i:=0;
      while not eoln do
      begin
        i:=i+1;
        read(a[i]);
      end;
      i:=1;
      repeat
        if a[i]>=85 then inc(b)
        else if a[i]>=75 then inc(c)
             else if a[i]>=60 then inc(d)
                  else inc(e);
        inc(i);
      until a[i]=0;
      writeln('A:',b);
      writeln('B:',c);
      writeln('C:',d);
      writeln('D:',e);
    end.
    
    • 1

    信息

    ID
    335
    时间
    1000ms
    内存
    128MiB
    难度
    10
    标签
    递交数
    1
    已通过
    0
    上传者