tailieunhanh - Absolute C++ (4th Edition) part 55

Absolute C++ (4th Edition) part 55. KEY BENEFIT: C++ programming concepts and techniques are presented in a straightforward style using understandable language and code. KEY TOPICS: C++ Basics; Flow of Control; Function Basics; Parameters and Overloading; Arrays; Structures and Classes; Constructors; Operator Overloading, Friends, and References; Strings; Pointers and Dynamic Arrays; Separate Compilation and Namespaces; Streams and File I/O; Recursion; Inheritance; Polymorphism and Virtual Functions; Templates; Linked Data Structures; Exception Handling; Standard Template Library; Patterns and UML. MARKET: Useful for both beginning and intermediate C++ programmers. . | Recursion RECURSIVE void FUNCTIONS 549 Example Vertical Numbers 549 Tracing a Recursive Call 552 A Closer Look at Recursion 555 Pitfall Infinite Recursion 556 Stacks for Recursion 558 Pitfall Stack Overflow 559 Recursion versus Iteration 559 RECURSIVE FUNCTIONS THAT RETURN A VALUE 561 General Form for a Recursive Function That Returns a Value 561 Example Another Powers Function 561 THINKING RECURSIVELY 566 Recursive Design Techniques 566 Binary Search 568 CHAPTER SUMMARY 576 ANSWERS TO SELF-TEST EXERCISES 576 PROGRAMMING PROJECTS 581 Recursion After a lecture on cosmology and the structure of the solar system William James was accosted by a little old lady. Your theory that the sun is the center of the solar system and the earth is a ball which rotates around it has a very convincing ring to it Mr. James but it s wrong. I ve got a better theory said the little old lady. And what is that madam inquired James politely. That we live on a crust of earth which is on the back of a giant turtle. Not wishing to demolish this absurd little theory by bringing to bear the masses of scientific evidence he had at his command James decided to gently dissuade his opponent by making her see some of the inadequacies of her position. If your theory is correct madam he asked what does this turtle stand on You re a very clever man Mr. James and that s a very good question replied the little old lady but I have an answer to it. And it is this the first turtle stands on the back of a second far larger turtle who stands directly under him. But what does this second turtle stand on persisted James patiently. To this the little old lady crowed triumphantly. It s no use Mr. James it s turtles all the way down. J. R. Ross Constraints on Variables in Syntax Introduction A function definition that includes a call to itself is said to be recursive. Like most modern programming languages C allows functions to be recursive. If used with a little care recursion can be a useful .

TỪ KHÓA LIÊN QUAN