I have a C++ project in which the ultimate goal is to create a calendar for any month and year. A part of the project requires that I first calculate the number of days from Jan 1, 0000 to any specified date. The function must take three parameters, representing year, month, and day. I am new to C++ so please cut me some slack if there is some incorrectly used commands or logic. So far this is what I have but the numbers are off by a few days when I test it. Can someone please tell me where my code went wrong?
int const day_of_forever(int const year, int const month, int const day)
{
int count[]={0,31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};
if ((year % 400==0) && (year % 100 != 0) && (year % 4 == 0 )&& (month>=2)) ((count[month-1]+day)+1);
return (count[month-1]+day)+(((year)*365)+1) +((year)/4)-(year/100)+(year/400);
}
void main()
{
int const year=2000;
int const day=1;
int const month=1;
int const something=day_of_forever(year,month,day);
print (something);
}
Aucun commentaire:
Enregistrer un commentaire