first day work

first day work。

 

study apex and apex api document.

 

 

 

基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip基于MATLAB实现旅行推销员问题(TSP)的代码+项目说明(课程大作业)+测试数据.zip 【备注】 1、该资源内项目代码百分百可运行,请放心下载使用!有问题请及时沟通交流。 2、适用人群:计算机相关专业(如计科、信息安全、数据科学与大数据技术、人工智能、通信、物联网、自动化、电子信息等)在校学生、专业老师或者企业员工下载使用。 3、用途:项目具有较高的学习借鉴价值,不仅适用于小白学习入门进阶。也可作为毕设项目、课程设计、大作业、初期项目立项演示等。 4、如果基础还行,或热爱钻研,亦可在此项目代码基础上进行修改添加,实现其他不同功能。 欢迎下载!欢迎交流学习!不清楚的可以私信问我!
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、付费专栏及课程。

余额充值