if-else分支结构,对输入分数给出评级

mac2024-11-09  8

// JudgeScore.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 //输入一个分数,输出该分数评级 #include <stdio.h> void legality(int grade) { if (grade > 100 || grade < 0) { printf("The score input is legality"); } } void main(){ int score; scanf_s("%d", &score); legality(score); if (score < 60) { printf("The score is E"); } else if ((score > 60 || score == 60) && score < 70) { printf("The score is D"); } else if ((score > 70 || score == 70) && score < 80) { printf("The score is C"); } else if ((score > 80 || score == 80) && score < 90) { printf("The score is B"); } else { printf("The score is A"); } }
最新回复(0)