C++ HDU 2005 第几天

来源:互联网 发布:网络通网站怎么买 编辑:程序博客网 时间:2024/05/16 07:15
#include<iostream>using namespace std;int main(){    int y, m,d,i,count=0;      bool leap;    char ch = '/';                      //题中的输入格式    while (cin >> y >> ch >> m >> ch >> d)    {        int a[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };        if (y % 4 == 0)                                          //判断闰年        {            if (y % 100 == 0)            {                if (y % 400 == 0)                    leap = true;                else                    leap = false;            }            else                leap = true;        }        else            leap = false;        if (leap)        {            a[1] = 29;        }        else        {            a[1] = 28;        }        for (i = 0; i < m - 1; i++)           {            count += a[i];        }        count += d;        cout << count << endl;        count = 0;    }    return 0;}
1 0
原创粉丝点击