C++ Programming for Games Module I phần 9

Tham khảo tài liệu 'c++ programming for games module i phần 9', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Write a program that does the following 1. Ask the user to enter up to a line of text and store it in a string s. 2. Transform each alphabetical character in s into its lowercase form. If a character is not an alphabetical character do not modify it. 3. Output the lowercase string to the console window. Your program output should look like this Enter a string Hello World Lowercase string hello world Press any key to continue Palindrome defines a palindrome as follows A word phrase verse or sentence that reads the same backward or forward. For example A man a plan a canal Panama For our purposes we will generalize and say that a palindrome can be any string that reads the same backwards or forwards and does not have to form a real word or sentence. Thus some simpler examples may be abcdedcba C C ProgrammingnimmargorP Write a program that does the following 1. Asks the user to enter up to a line of text and store it in a string s. 2. Tests if the string s is a palindrome. 3. If s is a palindrome then output s is a palindrome else output s is not a palindrome. Your program output should look like this Enter a string Hello World Hello World is not a palindrome Press any key to continue Another sample output Enter a string abcdedcba abcdedcba is a palindrome Press any key to continue 221 Chapter 7 -I--------------------- Operator Overloading 222 Introduction In the previous chapter we saw that we could access a character in a std string object using the bracket operator . Moreover we also saw that we could add two std strings together using the addition operator and that we could use the relational operators etc with std string objects as well. So it appears that we can use some C operators with std string. We may assume that perhaps these operators are defined for every class. However a quick test verifies that this is not the case class Fraction public Fraction Fraction float num float den float Numerator float mDenominator Fraction Fraction .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
106    109    3    14-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.