#include <iostream>using namespace std;struct date{int y;//yearint m;//monthint d;//day in Month};bool isLeap (int y )//Determine if it is a leap year {return y%4==0&&y%100!=0| | y%400==0;//true return is 1, false for 0}int daysofmonth (int y,int m) {int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};if (m!=2) return Day[m-1];else return 28+isleap (y);} int daysofdate (Date D)//calculates the total number of days {int days=d.d;for (int y=1;y<d.y;y++)//Calculation year days+=365+isleap (y); for (int m=1;m<d.m ; m++)//Calculate month days+=daysofmonth (d.y,m);//days+=d.d;return days;} int main () {Date d1,d2;cout<< "Intput 2 dates (yyyy mm DD):";cin>>d1.y>>d1.m>>d1.d;cin>> D2.y>>d2.m>>d2.d;int days1=daysofdate (d1); int days2=daysofdate (D2);cout<< "difference:" << days2-days1<<endl;cout<< "weekday" <<days1%7<< "\ T" <<days2%7<<endl;return 0;}
"C + + program" arbitrarily gives two dates, calculates the difference of how many days and the respective day of the week