fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // your code goes here
  5. #include <stdio.h>
  6. int main(void) {
  7. int score;
  8. printf("请输入分数:");
  9. scanf("%d", &score);
  10.  
  11. if (score < 0 || score > 100) {
  12. printf("error!\n");
  13. return 0;
  14. }
  15.  
  16. // 用整数除法把分数分段,简化switch分支
  17. switch(score / 10) {
  18. case 10:
  19. case 9:
  20. case 8:
  21. // 85~100:8/9/10分位,且8开头要≥85
  22. if (score >= 85) printf("A\n");
  23. else printf("B\n");
  24. break;
  25. case 7: printf("B\n"); break;
  26. case 6: printf("C\n"); break;
  27. default: printf("D\n"); // 0~59
  28. }
  29. return 0;
  30. }
  31.  
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 5312KB
stdin
69
stdout
Standard output is empty