1 条题解

  • 0
    @ 2025-4-7 21:28:48

    C :

    #include<stdio.h>
    char f(int x){
      if(x<60) return 'E';
      if(x>=60&&x<70) return 'D';
      if(x>=70&&x<80) return 'C';
      if(x>=80&&x<90) return 'B';
      return 'A';
    }
    int main(){
      int a;
      scanf("%d",&a);
      printf("%c",f(a));
      return 0;
    }
    

    C++ :

    #include<stdio.h>
    int main()
    {
    int a;
      scanf("%d",&a);
    if(a>=90)printf("A");
    else if(a>=80)printf("B");
    else if(a>=70) printf("C");
    else if(a>=60) printf("D");
    else printf("E");
    }
    
    

    Pascal :

    var
      n:longint;
    begin
      readln(n);
      if n>=90 then writeln('A') else
        if n>=80 then writeln('B') else
          if n>=70 then writeln('C') else
            if n>=60 then writeln('D') else
              writeln('E');
    end.
    

    Java :

    
    
    import java.util.Scanner;
    
    public class Main {
       private static Scanner s = new Scanner(System.in) ;
       
       public static void main(String[] args) {
    	  int score = s.nextInt() ;
    	  
    	  System.out.println(f(score)) ;
       }
       
       public static String f(int score){
    	   String temp = "" ;
    	   
    	   if(score>=90){
    		   temp = "A" ;
    	   }else if(80<=score&&score<90){
    		   temp = "B" ;
    	   }else if(70<=score&&score<80){
    		   temp = "C" ;
    	   }else if(60<=score&&score<70){
    		   temp = "D" ;
    	   }else if(score<60){
    		   temp = "E" ;
    	   }
    	   return temp ;
       }
    }
    
    

    Python :

    a = input()
    print 'A' if a >= 90 else 'B' if 80 <= a < 90 else 'C' if 70 <= a < 80 else 'D' if 60 <= a < 70 else 'E'
    
    • 1

    C语言程序设计教程(第三版)课后习题5.6

    信息

    ID
    1403
    时间
    1000ms
    内存
    64MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者