Algorithm intensive training: Day 32

Article directory

  • Taobao store
  • Fibonacci Phoenix Tail

1. Taobao store IO link

Ideas for this question: This question is a simple grammar question, just follow the meaning of the question.

#include <iostream>
using namespace std;
int main()
{
    int arr[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    int year1,month1,day1,year2,month2,day2;
    while(cin>>year1>>month1>>day1>>year2>>month2>>day2)
    {
    int ret=0;
        day1--;//1号到1号也会盈利一天,所以提前将day1减一天方便直接做减法计算能盈利的天数
        while(year1<year2||month1<month2)
        {
            
            //如果前者的日期和后者的日期还不在同一个年月,则ret累加day1到月底的盈利
            //如果是闰年的2月则一共29天,否则直接使用arr数组

Guess you like

Origin blog.csdn.net/qq_67458830/article/details/132807379