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
|
#include<iostream>
#include<cstdlib>
using namespace std;
int DetermineDayWeek(int, int, int);
int dd, mm, yy, a = 0;
int main()
{
do
{
cout <<endl << "Enter Month: " ;
cin >> mm;
cout << "Enter Day : " ;
cin >> dd;
cout << "Enter Year: " ;
cin >> yy;
if(yy <= 1912)
cout<<"This person is 100 years of age or older"<<endl;
}
while(dd > 0 && mm > 0 && yy > 0);
if(dd == 0 && mm == 0 && yy == 0)
{
DetermineDayWeek(dd, mm, yy);
}
return 0;
}
int DetermineDayWeek(int dd, int mm, int yy)
{
int months[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
if( yy % 4 == 0 )
{
months[1] = 29;
}
for(int i = mm-1; i > 0; i--)
{
a += months[i-1];
}
cout << a + dd << endl;
return 0;
}
|