0
点赞
收藏
分享

微信扫一扫

嵌套if语句

纽二 2022-05-03 阅读 31
c++
#include<iostream>
using namespace std;
int main()
{
	//选择结构 多条件if语句
	/*
	1.输入一个分数
	2.如果分数大于等于600,考上一本大学
	   考上700,考上北大
	   考上650,考上清华
	   其余     考上人大



	3.如果大于等于500小于600,考上二本
	4.如果大于400等于小于500,考上三本
	5.如果小于400,本科
	6.以上均在屏幕显示考上结果
	*/

	//1.提示用户输入分数

	int score1 = 0;
	cout << "请输入你的分数:" << endl;
	cin >> score1;
	cout << "你的分数是:" << score1 << endl;

	//2.判断分数
	if (score1 >= 600)
	{
		cout << "恭喜你考上一本大学" << endl;
		if (score1 > 700)
		{
			cout << "你考上了北大" << endl;
		}
		else if (score1 > 650)
		{
			cout << "你考上了清华" << endl;
		}
		else if (score1 > 600)
		{
			cout << "你考上了人大" << endl;
		}
	} 


	  

	else if (score1 >= 500)
	{
		cout << "恭喜你考上了二本大学" << endl;
	}
	else if (score1 >= 400)
	{
		cout << "恭喜你考上三本大学" << endl;
	}
	else if (score1 < 400)
	{
		cout << "恭喜你没有大学,只能读本科了" << endl;
	}


	else
	{
		cout << "请不要乱输入" << endl;

	}


	system("pause");
	return 0;

}
举报

相关推荐

0 条评论