《C++游戏编程入门》第2章 真值、分支与游戏循环: Guess My Number

2.1 关系运算符

==, !=
>, >=
<, <=

2.2 条件语句

02.score_rater.cpp
#include <iostream>
using namespace std;

int main()
{
   
	if (true)
	{
   
		cout << "This is always displayed.\n\n";
	}

	if (false)
		cout << "This is never displayed.\n\n";

	int score = 1000;

	if (score)
	{
   
		cout << "At least you didn't score zero.\n\n";
	}

	if (score >= 250)
		cout << "You scored 250 or more. Decent.\n\n";

	if (score >= 500)
	{
   
		cout << "You scored 500 or more. Nice.\n\n";

		if (score >= 1000)
			cout << "You scored 1000 or more. Impressive!\n";
	}

	return 0;
}
02.score_rater2.cpp
#include <iostream>
using namespace std;

int main()
{
   
	int score;
	cout << "Enter your score: ";
	cin >> score;

	if (score >= 1000)
		cout << "You scored 1000 or more. Impressive!\n";
	else
		cout << "You scored less than 1000.\n";

	return 0;
}
02.score_rater3.cpp
#include <iostream>
using namespace std;

int main()
{
   
	int score;
	cout << "Enter your score: ";
	cin >> score;

	if (score >= 1000)
	{
   
		cout 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值