练习4.8
相等性优先级>逻辑与>逻辑或
练习4.9
if(cp && *cp)如果cp为空指针和cp中的第一个字符不为空则为真。
练习4.10
#include "stdafx.h"
#include<iostream>
#include<string>
#include<vector>
using namespace::std;
int main()
{
int word;
while (cin >> word && word != 42)
{
cout << word << endl;
}
system("pause");
return 0;
}练习4.11
#include "stdafx.h"
#include<iostream>
#include<string>
#include<vector>
using namespace::std;
int main()
{
int a,b,c,d;
cin >> a >> b >> c >> d;
if (a > b && b > c && c > d)
{
cout << a << b << c << d;
}
else
{
cout << "错误" << endl;
}
system("pause");
return 0;
}练习4.12
i!=j<k //因为小于号的优先级大于不等于号所以右边返回一个bool类型0或1 则判断i与1或0的关系
本文包含多个C++编程练习示例,涉及条件判断与循环结构的应用,通过具体代码展示了如何使用逻辑运算符进行条件判断及循环控制。
279

被折叠的 条评论
为什么被折叠?



