【JiuDu OJ 04】what day is Date?

网友投稿 597 2022-10-10

【JiuDu OJ 04】what day is Date?

【JiuDu OJ 04】what day is Date?

【JiuDu OJ 04】what day is Date?

文章目录

​​【JiuDu OJ 04】what day is Date?​​​​一、Task​​​​二、process of solute​​

The problem is related in “​​Date​​”. After we contacted the basic problem about Date,the other questions will be solved through the basic of Date’s question.

The last time,I writed a Blog about ​​Date​​,which is named “​​《How many days between the date to date?》​​”.we could use the same methods to solve today’s problem.

Thinking:

what day is Date?we need Know:

what day is today?How many days between the today to that days,This problem gived,You need to use​​mood 7​​.

一、Task

二、process of solute

We used the methods ,using the interval of days to solve this problems , in order to show a method of basic Date’s problems .

#include#include#define IsYeap(x) x%100!=0&&x%4==0 ||x%400==0?1:0int DayOfMonth[13][2]= { 0,0, 31,31, 28,29, 31,31, 30,30, 31,31, 30,30, 31,31, 31,31, 30,30, 31,31, 30,30, 31,31 };char MonthName[13][20]= { " ", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" };char WeekName[7][20]= { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };int buf[3001][13][32];struct Date{ int Day; int Month; int Year; void nextDay() { Day++; if(Day>DayOfMonth[Month][IsYeap(Year)]) { Day=1; Month++; if(Month>12) { Month=1; Year++; } } }};int main(){ Date tmp; tmp.Day=1; tmp.Month=1; tmp.Year=0; int cnt=0; while(tmp.Year<3001) { buf[tmp.Year][tmp.Month][tmp.Day]=cnt; cnt++; tmp.nextDay(); } int day,month,year; char Month[20]; while(scanf("%d%s%d",&day,&Month,&year)!=EOF) { for(int i=1;i<13;i++) { if(strcmp(MonthName[i],Month)==0) { month=i; break; } } int k=buf[year][month][day]-buf[2018][12][31]+1; int j=(k%7+7)%7; printf("%s",WeekName[j]); }}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:骆驼小店-基于Python/Django的微信小程序商城
下一篇:SpringBoot中使用Thymeleaf模板详情
相关文章

 发表评论

暂时没有评论,来抢沙发吧~