C++ by Dissection 2002 phần 9

Chức năng ảo yêu cầu công việc bổ sung trong thời gian chạy và ít hiệu quả hơn các phương pháp nonvirtual. C + + lập trình sử dụng chúng khi cần thiết. Ảo chức năng và chức năng thành viên quá tải gây ra sự nhầm lẫn. | Ira Pohl s C by Dissection Exercises 391 Exercises 1. Write an array of strings to a file named . Initialize the array with the four strings I am a text file written and to . 2. Create an array of strings that receive their input from the file . Specify the number of strings by asking the user to enter the number of lines to be read. Echo the strings read to cout. 3. Redo the preceding exercise to end when the input is a special sentinel string. For example you may use an empty string as the sentinel. 4. Write a program that prints 1 000 random numbers to a file. 5. Write a program to read 1 000 random numbers in the range 0 to 1 from a file see exercise 4 and plot their distribution. That is divide the interval 0-1 into tenths and count the numbers that fall into each tenth. This gives you some confidence in their randomness. 6. Modify the preceding two exeic. ises to allow the usrr to specify the numbrr of random numbers and the name of the file on the command line. Store the number of generated numbers as the first entry in the file. 7. Read a text file and write it to a target text file changing all lowercase to uppercase and double spacing the output text. 8. Modify the program in the previous exercise to number each nonblank line. 9. Write a class dollar. Have its overloaded I O operators print a number such as as 12 . You should decide whether this class should internally store a dollar amount as two ints or a simple double. 10. Write a program that reads a text file and compiiles the reSative i rec ncy f each of the letters of the alphabet. You can use an array of length 26 to store the number of occurrences of each letter. You can use tolower to convert uppercase letters. Subtracting a then gives you a value in the range 0 to 25 inclusive which you can use to index into the array of counts. 11. Run the program from the previous exercise on several large text files and compare the results. How can you use .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
2    992    1    27-06-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.