设为首页 加入收藏

TOP

5.2 Relational and Logical Operators (3)
2013-10-07 15:23:33 来源: 作者: 【 】 浏览:71
Tags:5.2 Relational and Logical Operators

EXERCISES SECTION 5.2

Exercise 5.5: Explain when operands are eva luated in the logical AND operator, logical OR operator, and equality operator.

Exercise 5.6: Explain the behavior of the following while condition:

  1. char *cp = "Hello World";  
  2. while (cp && *cp) 

Exercise 5.7: Write the condition for a while loop that would read ints from the standard input and stop when the value read is equal to 42.

Exercise 5.8: Write an expression that tests four values, a, b, c, and d, and ensures that a is greater than b, which is greater than c, which is greater than d.

一般只有在非常底层的编程(www.cppentry.com)中才会用到按位操作符。

我注意到有些初学者过分关注微观(语句级)性能,比方说关心 while(true)和 for(;;) 哪个更快,++i 与i=i+1 哪个更快,i/=16 和 i>>= 4 哪个快,等等。而且受一些过时的教科书的影响,他们往往以为使用位运算代表“高效”,并为此牺牲代码的清晰性。我认为这是很不值得的。

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇5.4.1 Assignment Is Right Assoc.. 下一篇5.2 Relational and Logical Oper..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Sphinx : 高性能SQL (2025-12-24 10:18:11)
·Pandas 性能优化 - (2025-12-24 10:18:08)
·MySQL 索引 - 菜鸟教 (2025-12-24 10:18:06)
·Shell 基本运算符 - (2025-12-24 09:52:56)
·Shell 函数 | 菜鸟教 (2025-12-24 09:52:54)