三天打鱼两天晒网

1990-1-1开始上班

办法非常蠢,懒得改了,记录一下

#include<stdio.h>
#include<math.h>
int IsLeapYear(int n);
int main()
{
	int year,month,days;
	int check01,check02=1;
	int detyear,i;
	check01=scanf("%4d-%2d-%2d",&year,&month,&days);
	if(month==1||3==month||5==month||7==month||8==month||10==month)
	{
		if(days>31||days<=0)
		{
			check02=0;
		}
	}
	if(4==month||6==month||9==month||11==month||12==month)
	{
		if(days>30||days<=0)
		{
			check02=0;
		}
	}
	if(2==month)
	{
		if(IsLeapYear(year))
		{
			if(days>29||days<=0)
			check02=0;
		}
		else
		{
			if(days>28||days<=0)
			check02=0;
		}
	}
	if(check01!=3||year<1990||month>=13||month<=0||check02==0)
	{
		printf("Invalid input");
		return 0;
	}
	detyear=year-1990;
	int detdate=0;
	for(i=1;i<=detyear;i++)
	{
		if(IsLeapYear(1990+i-1))
			detdate+=366;
		else
			detdate+=365;
	}
	for(i=1;i<month;i++)
	{
		if(1==i||i==3||i==5||i==7||8==i||10==i)
		{
			detdate+=31;
		}
		else if(4==i||6==i||9==i||11==i||12==i)
		{
			detdate+=30;
		}
		else if(2==i)
		{
			if(IsLeapYear(year))
			{
				detdate+=29;
			}
			else
			{
				detdate+=28;
			}
		}
		
	}
	detdate+=days-1;
	printf("%d",detdate);
	int mark;
	mark=detdate%5;
	if(mark<=3)
	{
		printf("He is working");
	}
	else
	{
		printf("He is having a rest");
	}
	return 0;
}
int IsLeapYear(int n)
{
	if(n%4==0&&n%100!=0||n%400==0)
	return 1;
	else 
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值