C++编程思想(thinking in c++)答案

时间:2011-12-04 04:11:22
【文件属性】:

文件名称:C++编程思想(thinking in c++)答案

文件大小:261KB

文件格式:ZIP

更新时间:2011-12-04 04:11:22

thinking c++ 思想 编程

是volume 1的课后答案,以前从网上下了几个,可是都不是,这个绝对正宗。先给2-1的答案。 2-1 Modify Hello.cpp so that it prints out your name and age (or shoe size, or your dog’s age, if that makes you feel better). Compile and run the program. Solution: The original Hello.cpp appeared in the text as follows: // Saying Hello with C++ #include // Stream declarations using namespace std; int main() { cout << "Hello, World! I am " << 8 << " Today!" << endl; } Here’s my rewrite: //: S02:Hello2.cpp #include using namespace std; int main() { cout << "Hello, World! I am Chuck Allison." << endl; cout << "I have two dogs:" << endl; cout << "Sheba, who is " << 5 << ", and" << endl; cout << "Muffy, who is 8." << endl; cout << "(I feel much better!)" << endl; } /* Output: Hello, World! I am Chuck Allison. I have two dogs: Sheba, who is 5, and Muffy, who is 8. (I feel much better!) */ ///:~ I chose to have separate statements that send output to cout, but I could have printed everything in a single statement if I had wanted, like the example in the text does. Note that in the case of Sheba’s age, I printed 5 as an integer, but for Muffy I included the numeral in the literal text. In this case it makes no difference, but when you print floating-point numbers that have decimals, you get 6 decimals by default. Bruce discusses later in the text how to control output of floating-point numbers.


网友评论

  • 不全,希望是全的,不全的版本百度上也有
  • 对于在学习C++的孩子还是很有助益的
  • 答案还是不全啊,不过还算清晰的,可以好好学习一下了
  • 答案不太全,不过正确度还行
  • 还是比较不错的
  • 有些不全,不过算是比较清晰的了
  • 有些不全,不过配合原书使用比较有帮助
  • 很好,这个书跟其他的这方面的书不同,针对有一点基础的人比较好
  • 很好,也很清晰,谢谢分享
  • 跟官网下的一样,节省了费用。不过源码并不是完整的,不是都有解答。