/*輸入一個年份和月份,判斷是否為閏年,輸出年的天數和月的天數*/
#include
void main()
{
int year,month;
cout<<"請輸入年份和月份:"<
cin>>year>>month;
if(year%4==0&&year%100!=0||year%400==0)
cout<<year<<"年的天數為:366天"<<endl;
else
cout<<year<<"年的天數為:365天"<<endl;
if(month==2)
{
if(year%4==0&&year%100!=0||year%400==0)
cout<<month<<"月的天數為29天"<<endl;
else
cout<<month<<"月的天數為28天"<<endl;
}
else
if(month==4||month==6||month==9||month==11)
cout<<month<<"月的天數為30天"<<endl;
else
cout<<month<<"月的天數為31天"<<endl;
}
#include
void foo(int year, int month, int& ycount, int& mcount)
{if(year%4==0&&year%100!=0||year%400==0)
ycount=366;
else
ycount=365;
if(month==2)
{
if(year%4==0&&year%100!=0||year%400==0)
mcount=29;
else
mcount=28;
}
else
if(month==4||month==6||month==9||month==11)
mcount=30;
else
mcount=31;
}
}
void main()
{
int year,month;
cout<<"請輸入年份和月份:"<
cin>>year>>month;
int mcount,ycount;
foo(year, month, ycount, mcount);
cout<<year<<"年的天數為:"<< ycount << "天"<<endl;
cout<<month<<"月的天數為" << mcount << "天"<<endl;
}