#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
long int y,i,count=0,m,d,j;
cout<<"Enter day-month-year.\n";
cin>>d;cout<<"/";cin>>m;cout<<"/";cin>>y;
for (i=1;i<y;i++)
{
if ((i%400==0)||((i%4==0)&&(i%100!=0)))
count= count+2;
else
count=count+1;
}
for(j=1;j<m;j++)
{switch(j)
{case 1:case 3:case 5: case 7: case 8: case 10: case 12: count=count+31;break;
case 2:if ((i%400==0)||((i%4==0)&&(i%100!=0))) count=count+29; else count=count+28;break;
default :count=count+30;
}
}
count=count+d-1;
switch (count%7)
{
case 0:cout<<"Mon\n";break;
case 1:cout<<"Tues\n";break;
case 2:cout<<"Wed\n";break;
case 3:cout<<"Thu\n";break;
case 4:cout<<"Fri\n";break;
case 5:cout<<"Sat\n";break;
case 6:cout<<"Sun\n";break;
}
getch();
}
No comments:
Post a Comment