您的位置:首页 > 其它

中国有句俗语叫“三天打鱼两天晒网”,《某人从1990年1月1日起开始“三天打鱼两天晒网”,即工作三天,然后再休息两天。问这个人在以后的某一天中是在工作还是在休息》博主_luojingcong_改进版.

2018-06-05 17:35 525 查看
#include<stdio.h>
int count_Days(int y,int m,int d);
int main()
{
    int s,year,month,day;
    scanf("%4d-%2d-%2d",&year,&month,&day);
    if(year<1990)
    {
        printf("Invalid input\n");
    }
    else if(month>12||month<0)
    {
        printf("Invalid input\n");
    }
    else if(day>31||day<0)
    {
        printf("Invalid input\n");
    }
    else{
    s=count_Days(year,month,day);
    switch(s)
    {
        case 1:printf( "He is working\n");break;
        case 2:printf("He is having a rest\n");break;
            default:break;
    }
    return 0;
    }
}
int count_Days(int y,int m,int d)
{
    int d1=0,d2=0,d3=0,year,sum=0,i;
    int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
    if((y%4==0&&y%100!=0)||y%400==0)
    {
        a[2]=29;
        year=366;
    }
    else
        year=365;
    d1=(y-1990)*year;
    for(i=1;i<m;i++)
    {
        d2+=a[i];
    }
    d3=d;
    sum=d1+d2+d3;
    if(sum%5<=3||sum%5>1)
        return 1;
    else
        return 0;
} 阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐