问题:
We now use the Gregorian style of dating in Russia. The leap years are years with number divisible by 4 but not divisible by 100, or divisible by 400.
For example, years 2004, 2180 and 2400 are leap. Years 2004, 2181 and 2300 are not leap.
Your task is to write a program which will compute the day of week corresponding to a given date in the nearest past or in the future using today’s agreement about dating.
输入:
There is one single line contains the day number d, month name M and year number y(1000≤y≤3000). The month name is the corresponding English name starting from the capital letter.
输出:
Output a single line with the English name of the day of week corresponding to the date, starting from the capital letter. All other letters must be in lower case.
实现代码:
#include <stdio.h>
#include <string.h>
char *week[]={"Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday","Sunday"};
char *month[]={"January","February","March","April",
"May","June","July","August","September","October",
"November","December"};
int main(){
int y,m,d,i,a;
char mon[15];
for(;~scanf("%d %s %d",&d,mon,&y);){
for(i=0;i<12;++i) if(!strcmp(mon,month[i])) break;
m=i+1;
if(m==1||m==2) {
m+=12;y--;
}
if((y<1752)||(y==1752&&m<9)||
(y==1752&&m==9&&d<3))
a=(d+2*m+3*(m+1)/5+y+y/4+5)%7;
else
a=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7;
printf("%s\n",week[a]);
}
return 0;
}
运行结果:
- 大小: 21.8 KB
分享到:
相关推荐
在本文中,我们将深入探讨欧母龙PLC(Omron PLC)编程中如何计算一周中的某一天,这个主题与提供的压缩文件"FB Calculate Day Of Week.rar"紧密相关。欧母龙PLC是一种广泛应用于自动化控制领域的可编程逻辑控制器,...
标题中的“Day of Week + Week Number + Auto BST adjustment”表明这个压缩包可能包含与编程相关的程序或配置,涉及到了时间日期处理以及自动调整夏令时(BST,British Summer Time)的逻辑。在工业自动化领域,如...
Day of week.exe
标题“Get the Day of Week that a Day Falls On”暗示了一个编程任务,即获取特定日期是星期几。这个功能在各种应用程序中都很常见,比如日历应用或者时间管理工具。让我们深入探讨一下相关知识点。 首先,我们...
For the purpose of distinction, astronomical reckoning drops the symbols AD and BC and uses a plus or minus sign before the year instead. The astronomical year +1 therefore corresponds to the year AD...
find by ISO-8601 numeric representation of day/** @var Day */$ today = Day :: getToday (); use Hrevert \ Day \ Day ;use Hrevert \ Day \ DayCollection ;$ days = new DayCollection ([
本资料主要探讨的是AB PLC的程序设计与应用,通过“Day of the week.rar”这个压缩包,我们可以深入学习如何利用AB PLC实现对一周七天不同工况的控制。 首先,我们要了解AB PLC的基础架构。AB PLC通常包含处理器...
int last_day_of_week = first_day_of_week + 6; // 星期日 now.set(Calendar.DATE, last_day_of_week); return now.getTime(); } /** * 获得所在月份的最后一天 * @param 当前月份所在的时间 * @...
java java_leetcode题解之Day of the Week.java
语言:Deutsch,English,Nederlands,Türkçe,español,italiano,русский 工具栏的简单日期。 这只是一周的日子。 与刚刚的时钟扩展! 注意:当前版本可能在Windows的某些版本的Chrome上存在问题。...
- `L`:表示“最后”,在Day of Month中表示当月的最后一天,在Day of Week中表示当周的最后一天(通常是周六)。 - `W`:表示工作日(周一至周五),只在Day of Month中使用,会找到距离指定日期最近的工作日。 ...
在得到日期的同时判断DAY OF WEEK星期几,在窗体上显示 5为各个按钮及标签添加监听 通过ActionPerform MousePressed实现其动作 6 保存日志 显示日志及删除日志,总过创建哈希表来进行文件的读写
工具栏的简单日期。这只是本周的一天。与JUST A CLOCK扩展配对! 注意:当前版本可能在某些版本的Windows版Chrome上存在问题。 进行修复; 挂紧 ========================-工具栏中的缩写星期几。...
此版本支持为一周的第一天不是星期一的国家/地区选择不同的第一天。 原始版本可以在 http://sourceforge.net/projects/phpdatepicker 找到它是在 GPL v3 下许可的,所以请随意使用和更改。
jd2dow - Julian date to day of week jd2doy - Julian date to year & day of year jd2gps - Julian date to GPS week & seconds of week jd2mjd - Julian date to Modified Julian date jd2yr - Julian date ...
ABPLC例程源码Day of Week + Week Number + Auto BST adjustment本资源系百度网盘分享地址
常用功能汇编语言代码汇总,包括:ASCII 至 DWORD,RegWrite,RegReadStr,RegRead, Tokenizer,十六进制字符串转 DWORD,浮点操作,缓冲区对齐计算器,GetFeaturesFlags,Exists,Day of Week,从资源中提取文件,...
使用MySQL Week, Week of Year, Day of Week, Weekday, YearWeek函数 - **WEEK()**: 返回一年中的第几周,默认情况下,一周的第一天为星期一。 - **WEEKOFYEAR()**: 同样返回一年中的第几周,但其计算方式略有不同...
Calculator Edits, Calendar Edits, Button Edits, Degree/Minute/Second Edits, Comboboxes, Month Comboboxes, Day of Week Comboboxes, Time Zone Comboboxes, Country Comboboxes, Duration Comboboxes, ...
(i) the total number of days January 1st, year 1 to this day, (ii) the total number of days January 1st of the year to the day, and (iii) the day of the week of this day (assuming January 1st of year...