当前位置:网站首页>Date calculation February 2, 2015

Date calculation February 2, 2015

2020-12-07 08:57:32 osc_ z7z4vuvs

Problem description
   Given a year y And an integer d, Ask the first of the year d What's the day ?
   Pay attention to the leap year 2 Monthly 29 God . One of the following conditions is leap year :
  1) The year is 4 Integer multiple , And it's not 100 Integer multiple ;
  2) The year is 400 Integer multiple .
Input format
   The first line of input contains an integer y, Indicates the year , The year is 1900 To 2015 Between ( contain 1900 and 2015).
   The second line of input contains an integer d,d stay 1 to 365 Between .
Output format
   Output two lines , One integer per row , The month and date of the answer respectively .
The sample input
2015
80
Sample output
3
21
The sample input
2000
40
Sample output
2
9




















The only way to do it is to 70 branch , Then think about the reason If input d=365 So the month is 13 了 , Not satisfied with the question , And then randomly 30 Change to 31, become 60 branch , Change to 29, become 50 branch ... It seems that the platform is based on the correct number of points for such countable results .
Code segment :


```cpp

```cpp
#include <iostream>

using namespace std;

int main()
{
   
   
    int run[12]= {
   
   31,29,31,30,31,30,31,31,30,31,30,31};
    int ping[12]= {
   
   31,28,31,30,31,30,31,31,30,31,30,31};
    int y,d,yue;
    cin>>y;
    cin>>d;
    int a[12];

    for(int i=0; i<12; i++)
    {
   
   
        if((y/4)==0&&(y/100)!=0&&(y/400==0))
        {
   
   
            a[i]=run[i];
        }
        else
        {
   
   
            a[i]=ping[i];
        }

    }

    yue=d/30+1;
    cout<<yue<<endl;
    switch(yue)
    {
   
   
    case 1:
        cout<<d;
        break;
    case 2:
        cout<<(d-a[0]);
        break;
    case 3:
        cout<<(d-(a[0]+a[1]));
        break;
    case 4:
        cout<<(d-(a[0]+a[1]+a[2]));
        break;
    case 5:
        cout<<d-(a[0]+a[1]+a[2]+a[3]);
        break;
    case 6:
        cout<<d-(a[0]+a[1]+a[2]+a[3]+a[4]);
        break;
    case 7:
        cout<<d-(a[0]+a[1]+a[2]+a[3]+a[4]+a[5]);
        break;
    case 8:
        cout<<d-(a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]);
        break;
    case 9:
        cout<<d-(a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]);
        break;
    case 10:

        cout<<d-(a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]);
        break;
    case 11:
        cout<<d-(a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]+a[9]);
        break;
    case 12:
        cout<<d-(a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]+a[9]+a[10]);
        break;
    default:
        break;
    }
}

版权声明
本文为[osc_ z7z4vuvs]所创,转载请带上原文链接,感谢
https://chowdera.com/2020/12/20201207085507039b.html