tailieunhanh - A Complete Guide to Programming in C++ part 20

A Complete Guide to Programming in C++ part 20. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | SOLUTIONS 169 Exercise 2 ------------------------------------------------------- Reads and compares lines of text. ------------------------------------------------------- include iostream include string using namespace std string header Testing palindromes prompt Enter a word line 50 - int main string word Empty string char key y cout n t header endl while key y key Y cout n line n prompt cin word Compares the first and last character the second and the second to last etc. int i 0 j - 1 for i j i --j if word i word j break if i j All characters equal cout nThe word word is a P A L I N D R O M E endl else cout nThe word word is not a palindrome endl cout nRepeat y n do key while key y key Y key n key N return 0 170 CHAPTER 9 THE STANDARD CLASS STRING Exercise 3 The program outputs the date and time a greeting is printed according the time of day. For example Date and time Thu Nov 28 09 01 37 2001 Have a wonderful morning chapter Functions This chapter describes how to write functions of your own. Besides the basic rules the following topics are discussed passing arguments definition of inline functions overloading functions and default arguments the principle of recursion. .

TỪ KHÓA LIÊN QUAN