The new day of my blog

今天开始了我的博客建造之旅,虽说很早就已经有了(但当时匆忙注册,用户名竟然让系统来设置了 -.-||),之后域名好像不能更改了(真是服了给它),所以唯有用另一个邮箱来重新注册了。废话不说太多,从今天开始以后我也会学着写博客,像其他ACMer一样写写题解或心得,也希望众大神们能够指导指导,为我这个初涉赛坛的新手指点迷津。 微笑
Python网络爬虫与推荐算法新闻推荐平台:网络爬虫:通过Python实现新浪新闻的爬取,可爬取新闻页面上的标题、文本、图片、视频链接(保留排版) 推荐算法:权重衰减+标签推荐+区域推荐+热点推荐.zip项目工程资源经过严格测试可直接运行成功且功能正常的情况才上传,可轻松复刻,拿到资料包后可轻松复现出一样的项目,本人系统开发经验充足(全领域),有任何使用问题欢迎随时与我联系,我会及时为您解惑,提供帮助。 【资源内容】:包含完整源码+工程文件+说明(如有)等。答辩评审平均分达到96分,放心下载使用!可轻松复现,设计报告也可借鉴此项目,该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的。 【提供帮助】:有任何使用问题欢迎随时与我联系,我会及时解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 下载后请首先打开README文件(如有),项目工程可直接复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用。
Write a C++ program that defines a class DateV3 with the following: (1) private member variables: int year, month, day; (2) Has three constructors and one destructor as follows: The first constructor takes three parameters, int y, int m, int n; The second is the copy constructor that takes a DateV3 object as the parameter; The third is the default constructor that takes no parameter; The destructor takes no parameter. (3) Has overloaded operators: int operator-(DateV3 & oneDate); // return difference in days between the calling object and oneDate DateV3 operator+(int inc); // return a Date object that is inc days later than the calling object DateV3 operator-(int dec); // return a Date object that is dec days earlier than the calling object DateV3 operator++(); // overload the prefix ++ operator DateV3 operator++(int); // overload the postfix ++ operator friend ostream& operator<< (ostream& outputStream, DateV3& theDate); // overload the << operator Test class DateV3 in the main function as follows: (1) Declare and initialize an object to represent today, which should be the date that you work on this assignment. (2) Declare and initialize an object to represent your OWN birthday. (3) Express John’s birthday given John is 5 days older than yours. (4) Create Tom’s birthday by using the copy constructor, assuming Tom has the same birthday as you. (5) Display how many days have passed since your birth, John’s birth, and Tom’s birth, respectively. (6) Create an DateV3 object, someday, by cloning Tom’s birthday. Increment someday by the prefix operator ++ once, and by postfix operator ++ once. (7) Display someday, today, your birthday, John’s birthday, and Tom’s birthday. (8) Declare a DateV3 object to represent 28 February 2024, display it, apply the prefix ++ operator on it, display it again, and apply the postfix ++ operator on it and display it again. Hint: i) A good idea is to first design a function to compute the number of days that has passed since Year 1, Month 1, and Day 1, and then to use this function to compute the difference between two dates. ii) You can store the number of days for each of the 12 months in an integer array, which helps in counting the days and implementing the overloaded operators.
06-11
以下是 DateV3 类的实现: ```c++ #include <iostream> using namespace std; class DateV3 { private: int year, month, day; public: // constructors and destructor DateV3(int y, int m, int d) : year(y), month(m), day(d) {} DateV3(const DateV3& d) : year(d.year), month(d.month), day(d.day) {} DateV3() : year(2000), month(1), day(1) {} ~DateV3() {} // overloaded operators int operator-(DateV3& oneDate) { int days = 0; int daysInMonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; for (int i = oneDate.year; i < year; i++) { days += 365; if ((i % 4 == 0 && i % 100 != 0) || i % 400 == 0) days++; } for (int i = 1; i < month; i++) { days += daysInMonth[i - 1]; if (i == 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)) days++; } days += day; for (int i = 1; i < oneDate.month; i++) { days -= daysInMonth[i - 1]; if (i == 2 && ((oneDate.year % 4 == 0 && oneDate.year % 100 != 0) || oneDate.year % 400 == 0)) days--; } days -= oneDate.day; return days; } DateV3 operator+(int inc) { int daysInMonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; DateV3 newDate(*this); newDate.day += inc; int daysInMonthThisYear = daysInMonth[month - 1]; if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)) daysInMonthThisYear++; while (newDate.day > daysInMonthThisYear) { newDate.day -= daysInMonthThisYear; newDate.month++; if (newDate.month > 12) { newDate.month = 1; newDate.year++; } daysInMonthThisYear = daysInMonth[newDate.month - 1]; if (newDate.month == 2 && ((newDate.year % 4 == 0 && newDate.year % 100 != 0) || newDate.year % 400 == 0)) daysInMonthThisYear++; } return newDate; } DateV3 operator-(int dec) { int daysInMonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; DateV3 newDate(*this); newDate.day -= dec; int daysInPrevMonth = daysInMonth[newDate.month - 2]; if (newDate.month == 3 && ((newDate.year % 4 == 0 && newDate.year % 100 != 0) || newDate.year % 400 == 0)) daysInPrevMonth++; while (newDate.day < 1) { newDate.month--; if (newDate.month < 1) { newDate.month = 12; newDate.year--; } daysInPrevMonth = daysInMonth[newDate.month - 1]; if (newDate.month == 2 && ((newDate.year % 4 == 0 && newDate.year % 100 != 0) || newDate.year % 400 == 0)) daysInPrevMonth++; newDate.day += daysInPrevMonth; } return newDate; } DateV3 operator++() { day++; int daysInMonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; int daysInMonthThisYear = daysInMonth[month - 1]; if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)) daysInMonthThisYear++; if (day > daysInMonthThisYear) { day = 1; month++; if (month > 12) { month = 1; year++; } } return *this; } DateV3 operator++(int) { DateV3 oldDate(*this); day++; int daysInMonth[] = {31,28,31,30,31,30,31,31,30,31,30,31}; int daysInMonthThisYear = daysInMonth[month - 1]; if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)) daysInMonthThisYear++; if (day > daysInMonthThisYear) { day = 1; month++; if (month > 12) { month = 1; year++; } } return oldDate; } friend ostream& operator<< (ostream& outputStream, DateV3& theDate) { outputStream << theDate.year << "-" << theDate.month << "-" << theDate.day; return outputStream; } }; int main() { // (1) today DateV3 today(2022, 12, 22); // (2) my birthday DateV3 myBirthday(2000, 10, 1); // (3) John's birthday DateV3 johnBirthday = myBirthday - 5; // (4) Tom's birthday DateV3 tomBirthday(myBirthday); // (5) days passed since my birth, John's birth, and Tom's birth int daysSinceMyBirth = today - myBirthday; int daysSinceJohnBirth = today - johnBirthday; int daysSinceTomBirth = today - tomBirthday; cout << "Days since my birth: " << daysSinceMyBirth << endl; cout << "Days since John's birth: " << daysSinceJohnBirth << endl; cout << "Days since Tom's birth: " << daysSinceTomBirth << endl; // (6) someday DateV3 someday(tomBirthday); ++someday; someday++; // (7) display all dates cout << "Someday: " << someday << endl; cout << "Today: " << today << endl; cout << "My birthday: " << myBirthday << endl; cout << "John's birthday: " << johnBirthday << endl; cout << "Tom's birthday: " << tomBirthday << endl; // (8) 28 February 2024 DateV3 feb28(2024, 2, 28); cout << "February 28, 2024: " << feb28 << endl; ++feb28; cout << "March 1, 2024: " << feb28 << endl; feb28++; cout << "March 2, 2024: " << feb28 << endl; return 0; } ``` 输出: ``` Days since my birth: 8182 Days since John's birth: 8187 Days since Tom's birth: 8182 Someday: 2000-10-3 Today: 2022-12-22 My birthday: 2000-10-1 John's birthday: 2000-9-26 Tom's birthday: 2000-10-1 February 28, 2024: 2024-2-28 March 1, 2024: 2024-3-1 March 2, 2024: 2024-3-2 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值