我需要计算给定日期的天数。一年有 366 天。然而,每个月都有不同的价值,我必须分配这些价值。有没有比我现在做的更快的方法?
#include<iostream>
using namespace std;
int main()
{
int day, month, year, dayNumber;
cout<< "Please enter the month, by numerical value:";
cin>> month;
cout<<"Please enter the day, by numerical value:";
cin>> day;
cout<<"Please enter the year, by numerical value:";
cin>> year;
if (month == 1)
{
dayNumber= day;
cout<< "Month;" << '\t'<< month << '\n'
<< "Day:"<<'\t'<< day<< '\n'
<< "Year:"<<'\t'<< year<<'\n'
<< "Day Number:"<< '\t'<< dayNumber<< endl;
}
else if(month==2)
{
dayNumber= day+31;
}
}