蔡勒公式 计算星期
#include<iostream>
#include<algorithm>
#include<string>
#include<ctime>
#include<cstdlib>
#include<cmath>
#include<iomanip>
#include<typeinfo>
#define _CRT_SECURE_NO_WARNINGS
using namespace std;
double distance(double x1, double y1, double x2, double y2)
{
return sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2));
}
/*void Switch(int a1, int a2)
{
int temp;
temp = a1;
a1 = a2;
a2 = temp;
}
void BubbleSort(int a[])
{
int Number = 3;
for (int i = 0; i < Number; i++)
for (int j = i; j < Number; j++)
if (a[i] > a[j])
{
int temp;
temp = a[j];
a[j] = a[i];
a[i] = temp;
}
}*/
int main()
{
cout << "Enter year: (e.g., 2012): ";
int year;
cin >> year;
cout << "Enter month : 1-12: ";
int month;
cin >> month;
cout << "Enter the day of the month: 1-31: ";
int day;
cin >> day;
char a[7][10] = { "Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday" };
if (month <= 2)
{
year -= 1;
month += 12;
}
int h = (day + 26 * (month + 1) / 10 + year % 100 + (year % 100) / 4 + ((year / 100)) / 4 + ((year / 100)) * 5) % 7;
cout << "Day of the week is " << a[h];
return 0;
}