计算一年有多少天

来源:互联网 发布:web微信开发工具linux 编辑:程序博客网 时间:2024/04/28 03:39
#include<iostream>
using namespace std;
int main()
{
 int year,month,day;
 int t=0;
 cin>>year>>month;
 if(year%400==0||(year%100!=0&&year%4==0))
  t=1;
 if(t==1)
 {
  if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
  cout<<"31"<<endl;
  if(month==4||month==6||month==9||month==11)
  cout<<"30"<<endl;
  if (month==2)
  cout<<"29"<<endl;
 }
    if(t==0)
 {
  if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
  cout<<"31"<<endl;
  if(month==4||month==6||month==9||month==11)
  cout<<"30"<<endl;
  if (month==2)
  cout<<"28"<<endl;
 }
 return 0;
}
0 0