> score; if (90 <= score && score <= 100) { //不能使用连续比较,跟数学不一样,比如a <= b <= c 应改为a<=b&..._你考试考了多少分csdn">
赞
踩
- #include <iostream>
- using namespace std;
- int main() {
- cout << "你考试考了多少分?(0~100)" << endl;
- int score;
- cin >> score;
- if (90 <= score && score <= 100) { //不能使用连续比较,跟数学不一样,比如a <= b <= c 应改为a<=b&&b<=c
- cout << "优" << endl;
- }
- else if (80 <= score && score < 90) {
- cout << "良" << endl;
- }
- else if (60 <= score && score < 80) {
- cout << "中" << endl;
- }
- else if (0 <= score && score < 60) {
- cout << "差" << endl;
- }
- return 0;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。