输入百分制成绩,输出等级。(用 switch 实现)

 

#include<stdio.h>

int main(void)
{
  int grade;
  scanf("%d", &grade);

  grade = grade / 10;
  switch (grade)
  {
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
      printf("F");
      break;
    case 6:
      printf("D");
      break;
    case 7:
      printf("C");
      break;
    case 8:
      printf("B");
      break;
    case 9:
    case 10:
      printf("A");
      break;
    default:
      break;
  }

  return 0;
}

 

说点什么

avatar

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

  Subscribe  
提醒