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

上传者: projoy | 上传时间: 2023-03-07 10:22:43 | 文件大小: 261KB | 文件类型: ZIP
是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.

文件下载

资源详情

[{"title":"( 193 个子文件 261KB ) C++编程思想(thinking in c++)答案","children":[{"title":"SafeVector.cpp <span style='color:#111;'> 1.21KB </span>","children":null,"spread":false},{"title":"VectorTest.cpp <span style='color:#111;'> 568B </span>","children":null,"spread":false},{"title":"fibonacci.cpp <span style='color:#111;'> 1.26KB </span>","children":null,"spread":false},{"title":"TemplateArray.cpp <span style='color:#111;'> 1.95KB </span>","children":null,"spread":false},{"title":"SelfCounter.cpp <span style='color:#111;'> 320B </span>","children":null,"spread":false},{"title":"NestedSmartPointerTemplate.cpp <span style='color:#111;'> 1.75KB </span>","children":null,"spread":false},{"title":"makefile <span style='color:#111;'> 2.12KB </span>","children":null,"spread":false},{"title":"SelfCounter.h <span style='color:#111;'> 1007B </span>","children":null,"spread":false},{"title":"ValueStack.h <span style='color:#111;'> 961B </span>","children":null,"spread":false},{"title":"PointerToMemberOperatorTemplate.cpp <span style='color:#111;'> 2.09KB </span>","children":null,"spread":false},{"title":"SpecializeReturn.cpp <span style='color:#111;'> 960B </span>","children":null,"spread":false},{"title":"GlobalConst.cpp <span style='color:#111;'> 274B </span>","children":null,"spread":false},{"title":"Volatile.cpp <span style='color:#111;'> 521B </span>","children":null,"spread":false},{"title":"Quoter.cpp <span style='color:#111;'> 417B </span>","children":null,"spread":false},{"title":"StringLiteral.cpp <span style='color:#111;'> 377B </span>","children":null,"spread":false},{"title":"ConstReference.cpp <span style='color:#111;'> 639B </span>","children":null,"spread":false},{"title":"ConstTime.c <span style='color:#111;'> 353B </span>","children":null,"spread":false},{"title":"makefile <span style='color:#111;'> 1.66KB </span>","children":null,"spread":false},{"title":"ConstTime.cpp <span style='color:#111;'> 464B </span>","children":null,"spread":false},{"title":"InitList.cpp <span style='color:#111;'> 575B </span>","children":null,"spread":false},{"title":"Announce.cpp <span style='color:#111;'> 874B </span>","children":null,"spread":false},{"title":"ArrayInit.cpp <span style='color:#111;'> 739B </span>","children":null,"spread":false},{"title":"forScope.cpp <span style='color:#111;'> 574B </span>","children":null,"spread":false},{"title":"makefile <span style='color:#111;'> 1001B </span>","children":null,"spread":false},{"title":"MessageWithPrefix.cpp <span style='color:#111;'> 691B </span>","children":null,"spread":false},{"title":"ManyArgs.cpp <span style='color:#111;'> 727B </span>","children":null,"spread":false},{"title":"Message.cpp <span style='color:#111;'> 724B </span>","children":null,"spread":false},{"title":"makefile <span style='color:#111;'> 1.38KB </span>","children":null,"spread":false},{"title":"NamelessArg.cpp <span style='color:#111;'> 532B </span>","children":null,"spread":false},{"title":"Text.cpp <span style='color:#111;'> 796B </span>","children":null,"spread":false},{"title":"DefaultArgs.cpp <span style='color:#111;'> 568B </span>","children":null,"spread":false},{"title":"PolymorphicWhatAmI.cpp <span style='color:#111;'> 833B </span>","children":null,"spread":false},{"title":"VirtualHit.cpp <span style='color:#111;'> 849B </span>","children":null,"spread":false},{"title":"AllMyRodents.cpp <span style='color:#111;'> 1.74KB </span>","children":null,"spread":false},{"title":"makefile <span style='color:#111;'> 1.81KB </span>","children":null,"spread":false},{"title":"VirtualClone.cpp <span style='color:#111;'> 946B </span>","children":null,"spread":false},{"title":"Instrument4.cpp <span style='color:#111;'> 3.04KB </span>","children":null,"spread":false},{"title":"InheritVirtuals.cpp <span style='color:#111;'> 740B </span>","children":null,"spread":false},{"title":"PolymorphicSizeof.cpp <span style='color:#111;'> 743B </span>","children":null,"spread":false},{"title":"SliceTheBase.cpp <span style='color:#111;'> 666B </span>","children":null,"spread":false},{"title":"StringCopy.cpp <span style='color:#111;'> 841B </span>","children":null,"spread":false},{"title":"UsesThis.cpp <span style='color:#111;'> 539B </span>","children":null,"spread":false},{"title":"makefile <span style='color:#111;'> 1.93KB </span>","children":null,"spread":false},{"title":"Exercise3.cpp <span style='color:#111;'> 297B </span>","children":null,"spread":false},{"title":"StructSize.cpp <span style='color:#111;'> 548B </span>","children":null,"spread":false},{"title":"GetSet.cpp <span style='color:#111;'> 476B </span>","children":null,"spread":false},{"title":"Sizeof.cpp <span style='color:#111;'> 567B </span>","children":null,"spread":false},{"title":"LinkedList.cpp <span style='color:#111;'> 1.45KB </span>","children":null,"spread":false},{"title":"Nested.cpp <span style='color:#111;'> 722B </span>","children":null,"spread":false},{"title":"MyStruct.cpp <span style='color:#111;'> 336B </span>","children":null,"spread":false},{"title":"MyStruct.h <span style='color:#111;'> 296B </span>","children":null,"spread":false},{"title":"Storage.cpp <span style='color:#111;'> 926B </span>","children":null,"spread":false},{"title":"CharArray.h <span style='color:#111;'> 525B </span>","children":null,"spread":false},{"title":"Exercise7.cpp <span style='color:#111;'> 308B </span>","children":null,"spread":false},{"title":"UseTRACE.cpp <span style='color:#111;'> 445B </span>","children":null,"spread":false},{"title":"CharArray.cpp <span style='color:#111;'> 398B </span>","children":null,"spread":false},{"title":"LinkError.cpp <span style='color:#111;'> 309B </span>","children":null,"spread":false},{"title":"FieldAccessors.cpp <span style='color:#111;'> 837B </span>","children":null,"spread":false},{"title":"ColorAndHue.cpp <span style='color:#111;'> 820B </span>","children":null,"spread":false},{"title":"makefile <span style='color:#111;'> 2.37KB </span>","children":null,"spread":false},{"title":"TrackTime.cpp <span style='color:#111;'> 1.01KB </span>","children":null,"spread":false},{"title":"UseDEBUG.cpp <span style='color:#111;'> 744B </span>","children":null,"spread":false},{"title":"FixMacroSideEffects.cpp <span style='color:#111;'> 803B </span>","children":null,"spread":false},{"title":"MemberObject.cpp <span style='color:#111;'> 431B </span>","children":null,"spread":false},{"title":"InternalLinkage.cpp <span style='color:#111;'> 331B </span>","children":null,"spread":false},{"title":"MapWords.cpp <span style='color:#111;'> 1.57KB </span>","children":null,"spread":false},{"title":"ProtoTest.cpp <span style='color:#111;'> 414B </span>","children":null,"spread":false},{"title":"struct.cpp <span style='color:#111;'> 795B </span>","children":null,"spread":false},{"title":"PointerIncrement2.cpp <span style='color:#111;'> 769B </span>","children":null,"spread":false},{"title":"FPtr1.cpp <span style='color:#111;'> 438B </span>","children":null,"spread":false},{"title":"MapFloat.cpp <span style='color:#111;'> 558B </span>","children":null,"spread":false},{"title":"PrintBinary.cpp <span style='color:#111;'> 408B </span>","children":null,"spread":false},{"title":"IEEEFloat.cpp <span style='color:#111;'> 886B </span>","children":null,"spread":false},{"title":"prime.cpp <span style='color:#111;'> 687B </span>","children":null,"spread":false},{"title":"trigraph.cpp <span style='color:#111;'> 580B </span>","children":null,"spread":false},{"title":"makefile <span style='color:#111;'> 3.27KB </span>","children":null,"spread":false},{"title":"no-trigraph.cpp <span style='color:#111;'> 459B </span>","children":null,"spread":false},{"title":"Enum.cpp <span style='color:#111;'> 453B </span>","children":null,"spread":false},{"title":"Prototypes.cpp <span style='color:#111;'> 638B </span>","children":null,"spread":false},{"title":"StringRef.cpp <span style='color:#111;'> 566B </span>","children":null,"spread":false},{"title":"Prototypes.h <span style='color:#111;'> 322B </span>","children":null,"spread":false},{"title":"StringArray.cpp <span style='color:#111;'> 615B </span>","children":null,"spread":false},{"title":"AbusingTheLanguage.cpp <span style='color:#111;'> 1.20KB </span>","children":null,"spread":false},{"title":"Vampire.cpp <span style='color:#111;'> 1.49KB </span>","children":null,"spread":false},{"title":"PrintBytes.cpp <span style='color:#111;'> 637B </span>","children":null,"spread":false},{"title":"makefile <span style='color:#111;'> 6.56KB </span>","children":null,"spread":false},{"title":"require.h <span style='color:#111;'> 1.62KB </span>","children":null,"spread":false},{"title":"HasInt.h <span style='color:#111;'> 1.82KB </span>","children":null,"spread":false},{"title":"BirdHouse.h <span style='color:#111;'> 716B </span>","children":null,"spread":false},{"title":"BirdHouse.cpp <span style='color:#111;'> 437B </span>","children":null,"spread":false},{"title":"Bird.h <span style='color:#111;'> 474B </span>","children":null,"spread":false},{"title":"PointerToMemberOperator.cpp <span style='color:#111;'> 1.13KB </span>","children":null,"spread":false},{"title":"ReflexiveAdd.cpp <span style='color:#111;'> 866B </span>","children":null,"spread":false},{"title":"CopyAssign.cpp <span style='color:#111;'> 1.40KB </span>","children":null,"spread":false},{"title":"HasInt.cpp <span style='color:#111;'> 356B </span>","children":null,"spread":false},{"title":"makefile <span style='color:#111;'> 2.20KB </span>","children":null,"spread":false},{"title":"Overloaded.cpp <span style='color:#111;'> 908B </span>","children":null,"spread":false},{"title":"NumberTest.cpp <span style='color:#111;'> 856B </span>","children":null,"spread":false},{"title":"Number.h <span style='color:#111;'> 1.63KB </span>","children":null,"spread":false},{"title":"TheBirds.cpp <span style='color:#111;'> 441B </span>","children":null,"spread":false},{"title":"......","children":null,"spread":false},{"title":"<span style='color:steelblue;'>文件过多,未全部展示</span>","children":null,"spread":false}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明