PDF Google Drive Downloader v1.1


Báo lỗi sự cố

Nội dung text W09-Struct-File IO.pdf

Week 09 Struct – File IO Introduction to Programming Department of Software Engineering-FIT-VNU-HCMUS
Introduction to Programming W09 – Struct – File IO 2 1 Content In this lab, we will study the following topics: • How to define and use a struct. • How to load data from text file. • How to save data to text file.
Introduction to Programming W09 – Struct – File IO 3 outputDateWithFormat(d1, "yyyy-MM-dd"); // 2019 - 12 - 04 outputDateWithFormat(d1, "MMM dd yy"); // Dec 12 19 2 Assignments A: YY = 05 H: YY = 25: at least 7 in struct Date + at least 7 in struct Student + at least 6 in struct Course 2.1 Assignment 1 Define a struct Date (day, month, year) and the following functions. 1. Input a date. 2. Output a date (yyyy-MM-dd). 3. Output a date with a given format. For example: yy: 70, yyyy: 1970, M: 8 or 12, MM: 08 or 12, MMM: Jan ... Dec, d: 1 or 29, dd: 01 or 29. 4. Load a date from a text file. 5. Save a date to another text file. 6. Compare 2 date. 7. Find tomorrow: increase a date by 1 day. 8. Find yesterday: decrease a date by 1 day. 9. Increase a date by k day. 10. Decrease a date by k day. 11. Compute the distance between input date vs 1/1/same year. 12. Compute the distance between input date vs 1/1/1970. 13. Compute the distance between 2 input dates. 14. Given that the date of week of 1970-01-01 is Thursday. Compute the date of week of the input date. Define a struct Student (id, full name, gpa, address, date of birth) and the following functions. 15. Input a student. 16. Output a student: id, full name, gpa, address, dob. 17. Output a student: id, first name (first word), last name (remaining words), gpa, address, dob, age (18 year 2 months, 2 days). 18. Load a student from a text file. 19. Save a student to a text file. 20. Extract the class of input student. For example, if your id is 19127001, you are in K19 class. 21. Compare 2 students by id. 22. Compare 2 students by gpa, and then by id. 23. Compare 2 students by name, and then by id. 24. Compare 2 students by first name, and then by id.
Introduction to Programming W09 – Struct – File IO 4 25. Compare 2 students by last name, and then by id. 26. Compare 2 students by dob, and then by id. Define a struct Course (course id, e.g. CS161, course name, e.g. Introduction to Programming, and an array of students, status, e.g. open, or close, maximum number of students in the course, minimum number of students in the course) and the following functions. 27. Load a course from text file. 28. Save a course to text file. 29. Add a student to a course. Check the maximum number of students in the course condition. 30. Remove a student to a course. Check minimum number of students in the course to update the course status: open or close. 31. Get the current date in your computer. Find all students who were born in this month and save to a text file. 32. Get the current date in your computer. Find all students who were born in this date and save to a text file. 33. Get the current date in your computer. Find all students who are legal to have driving licences (>= 18 years old) and save to a text file. 34. Find all students are in K19 class and save to a text file. 35. Find a student by a given id. Save the answer to a text file. 36. Find a student by a given name (“thanh” vs “Tuan-Thanh Ho”). Save the answers to a text file. 37. Sort students by id. Save the answers to a text file. 38. Sort students by first name. Save the answers to a text file. 39. Sort students by gpa. Save the answers to a text file. 40. Sort students by dob. Save the answers to a text file. 2.2 Guide to Reading and Writing Text Files #include #include #include #include using namespace std; struct Date { int day, month, year; }; /// Hàm tạo Date từ luồng nhập Date InputDate(istream &is) { Date d; is >> d.day >> d.month >> d.year; return d; } /// Hàm xuất Date ra luồng xuất void OutputDateWithFormat(ostream &os, Date d, const char sFormat[]) { os << setfill('0'); if (strcmp(sFormat, "yyyy-MM-dd") == 0) { os << setw(4) << d.year << '-'; os << setw(2) << d.month << '-';

Tài liệu liên quan

x
Báo cáo lỗi download
Nội dung báo cáo



Chất lượng file Download bị lỗi:
Họ tên:
Email:
Bình luận
Trong quá trình tải gặp lỗi, sự cố,.. hoặc có thắc mắc gì vui lòng để lại bình luận dưới đây. Xin cảm ơn.