打鱼还是晒网
Posted yuanxinglan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了打鱼还是晒网相关的知识,希望对你有一定的参考价值。
#include<stdio.h>
typedef struct date
int year;
int month;
int day;
DATE;
int countDay(DATE);
int runYear(int);
int main()
DATE today;
int totalday;
int result;
printf("请输入指定的日期(如:2001 2 34): ");
scanf("%d%d%d",&today.year,&today.month,&today.day);
totalday=countDay(today);
result=totalday%5;
if(result>0 && result<4)
printf("%d年%d月%d日出海打鱼",today.year,today.month,today.day);
else
printf("%d年%d月%d日出海晒网",today.year,today.month,today.day);
return 0;
int runYear(int year)
if((year%4==0 && year%100!=0)||(year%400==0))
return 1;
else
return 0;
int countDay(DATE currentDay)
int perMonth[13]=0,31,28,31,30,31,30,31,31,30,31,30,31;
int totalDay=0,year,i;
for(year =1990;year<=currentDay.year;year++)
if(runYear(year))
totalDay=totalDay+366;
else
totalDay=totalDay+365;
if(runYear(currentDay.year))
perMonth[2]+=1;
for(i=0;i<currentDay.month;i++)
totalDay+=perMonth[i];
totalDay+=currentDay.day;
return totalDay;
实验3-9 三天打鱼两天晒网 (15分)
国有句俗语叫“三天打鱼两天晒网”。假设某人从某天起,开始“三天打鱼两天晒网”,问这个人在以后的第N天中是“打鱼”还是“晒网”?
输入格式:
输入在一行中给出一个不超过1000的正整数N。
输出格式:
在一行中输出此人在第N天中是“Fishing”(即“打鱼”)还是“Drying”(即“晒网”),并且输出“in day N”。
输入样例1:
103
输出样例1:
Fishing in day 103
输入样例2:
34
输出样例2:
Drying in day 34
以上是关于打鱼还是晒网的主要内容,如果未能解决你的问题,请参考以下文章