1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
#include <iostream>
#include <string>
using namespace std;
int main()
{
int inc[12] = { 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 };
int y, m, d, t = 0, dx = 0;
do
{
cout << "Enter Year";
cin >> y;
}
while(y<1753);
string w[7] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
int a, c;
if (y>2013)
{
for (int i = 2013; i<y; i++)
{
if ((i % 4 == 0 && i % 100 != 0) || (i % 400 == 0))
t = t + 1;
}
a = y - 2013;
c = (1 + a + t) % 7;
}
if (y <= 2013)
{
for (int i = 2013; i >= y; i--)
{
if ((i % 4 == 0 && i % 100 != 0) || (i % 400 == 0))
t = t + 1;
}
a = 2013 - y;
c = (((1 - a - t) % 7) + 7) % 7;
}
do
{
cout << "Enter Month(1 to 12)";
cin >> m;
} while (m < 1 || 12 < m);
while (dx != 1)
{
cout << "Enter day";
cin >> d;
if (((m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) && (0 < d &&d < 32)) || ((m == 4 || m == 6 || m == 9 || m == 11) && (1 <= d || d <= 30)) || ((m == 2) && ((0 < d&&d < 29) || (((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)) && (0<d&&d<30)))))
dx = 1;
}
a = c + inc[m - 1];
if ((2 < m) && (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)))
a = a + 1;
for (int i = 0; i < 7; i++)
cout << w[(a + i) % 7] << "\t";
cout << endl;
for (int j = 0; j < 4; j++)
{
for (int i = 1; i < 8; i++)
cout << i + (7 * j) << "\t";
cout << endl;
}
if ((m == 2) && ((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0)))
cout << "29" << endl;
if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)
cout << "29\t30\t31" << endl;
if (m == 4 || m == 6 || m == 9 || m == 11)
cout << "29\t30" << endl;
cout << w[(a + d - 1) % 7] << " is the day on that day.\n";
system("pause");
}
|