❶ c語言編寫程序,輸入某年某月,求該月的天數
#include<iostream.h>
voidmain()
{
intYear,Month,Day;
cout<<"Pleaseenterthecurrentdate(年月以空格分隔):";
cin>>Year>>Month;
while(Month<=0||Month>12)
{
cout<<"輸入時間有誤,請重新輸入:";
cin>>Year>>Month;
}
switch(Month)
{
case4:
case6:
case8:
case9:
case11:
Day=30;
break;
case2:
if(Year%400==0||Year%4==0&&nYear%100!=0)
Day=29;
else
Day=28;
break;
default:Day=31;
}
cout<<"該月天數為:"<<Day<<"天";
}
❷ 用c語言編寫萬年歷,要求輸出任意一年的某月,能顯示出這個月的日歷
1、首先要判斷一個年份是閏年還是平年,用一個子程序來做。