文章

82

粉丝

343

获赞

27

访问

662.4k

头像
超级暴力详解
P1290 上海交通大学/西北工业大学2019机试
发布于2021年1月19日 13:04
阅读数 9.1k

/*

闰年:能被400整除或者能被4整除并且不能被10整除

用数组存储闰年每一个月和平年每一个月

三种情况: 

case1.年月相同

   直接做差加一

case2.年同月不同

   判断当前年份是否为闰年若是闰年利用闰年数组否则利用平年数组

case3.年不同

  分为三部分,开始年份剩余的天数+中间年份天数+结束年份天数

  闰年366 平年365

*/

#include <iostream>
using namespace std;

int year1,year2;
int month1,month2;
int day1,day2;
char a[8];
char b[8];
int p_year[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};//平年 
int r_year[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};//闰年 
bool runnian(int x){
    if(x%400==0) return true;
    if(x%4==0&&x%100!=0) return true;
    return false;
}
int main(){
    while(scanf("%s %s",&a,&b)!=EOF){
    year1=(a[0]-'0')*1000+(a[1]-'0')*100+(a[2]-'0')*10+a[3]-'0';
    year2=(b[0]-'0')*1000+(b[1]-'0')*100+(b[2]-'0')*10+b[3]-'0';
&nbs...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发