123456789101112131415161718192021
#include <iostream> #include <string> using namespace std; int main(void) { string Days[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday", "Friday","Saturday"}; int a,month,year,y,day,m,d; cout <<"Enter the month (1-12): "; cin >>month; cout <<"Enter the date (1-31): "; cin >>day; cout <<"Enter the year (>1582): "; cin >>year; cout <<endl <<"The Date: "<<month<<"/"<<day<<"/"<<year <<" Falls on a: "<< Days[d]<<endl; return 0; }
123456
// Assume that month, day and year have been read in a = (14-month)/12; y=year-a; m = month+12*a-2; d = (day+y+y/4-y/100+y/400+(31*m/12))%7;