if (month == 01)
{
if (leap) m = 6;
else m = 0;
}
if (month == 02)
{
if (leap) m = 2;
else m = 3;
}
if (month == 03)
{
m = 3;
}
if (month == 04)
{
m = 6;
}
if (month == 05)
{
m = 1;
}
if (month == 06)
{
m = 4;
}
if (month == 07)
{
m = 6;
}
if (month == 8)
{
m = 2;
}
if (month == 9)
{
m = 5;
}
if (month == 10)
{
m = 0;
}
if (month == 11)
{
m = 3;
}
if (month == 12)
{
m = 5;
}
u = (2*(3-(year/100%4)));
v = year-(year/100)*100;
w = (v/4);
y = u+v+w+m+day;
dayofweek=y%7;
if (dayofweek == 0)
dayname = "Sunday, ";
else if (dayofweek == 1)
dayname = "Monday, ";
else if (dayofweek == 2)
dayname = "Tuesday, ";
else if (dayofweek == 3)
dayname = "Wednesday, ";
else if (dayofweek == 4)
dayname = "Thursday, ";
else if (dayofweek == 5)
dayname = "Friday, ";
else if (dayofweek == 6)
dayname = "Saturday, ";
cout<< dayname << monthname << day << "," << year << "occured in a";
if (leap)
cout<< "leap year.";
It works fine here, so maybe you just wonder why the window closes so fast ^^
write system("pause") at the end of the programm, then the window will stay open ;)