⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1201 18岁生日.cpp

📁 威士忌的HDU题解.大概有260多题的源码。对于学习非常有好处。
💻 CPP
字号:
/*
1201 18岁生日
Time Limit : 1000 ms  Memory Limit : 32768 K  Output Limit : 256 K

GUN C++
*/
#include<iostream>
#include<stdio.h>
using namespace std;

bool LeapYear(int year)
{
   if ((year%100!=0 && year%4==0) || (year%400==0)) return true;
   return false;
}

void run()
{
   int year, month, day;
   scanf("%d-%d-%d", &year, &month, &day);

   if(month==2 && day==29 && !LeapYear(year+18)){
       cout<<"-1"<<endl;
   }
   else{
       int count=0;   // 统计期间经过的闰年数
       if (!(month<=2 && day<=28))
           year++;

       for(int i=year; i<year+18; i++){
           if(LeapYear(i))    count++;
       }

       int days=18*365+count;
       cout<<days<<endl;
   }
}

int main()
{
   int total;
   cin>>total;
   for(int now=1; now<=total; now++) run();

   return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -