问题:
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
分享到:
相关推荐
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...
欧母龙PLC例程_本资料仅供学习参考
AB PLC例程_本资料仅供学习参考
find by ISO-8601 numeric representation of day/** @var Day */$ today = Day :: getToday (); use Hrevert \ Day \ Day ;use Hrevert \ Day \ DayCollection ;$ days = new DayCollection ([
int last_day_of_week = first_day_of_week + 6; // 星期日 now.set(Calendar.DATE, last_day_of_week); return now.getTime(); } /** * 获得所在月份的最后一天 * @param 当前月份所在的时间 * @...
语言:Deutsch,English,Nederlands,Türkçe,español,italiano,русский 工具栏的简单日期。 这只是一周的日子。 与刚刚的时钟扩展! 注意:当前版本可能在Windows的某些版本的Chrome上存在问题。...
在得到日期的同时判断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,从资源中提取文件,...
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...
AB PLC例程_本资料仅供学习参考
$ ./calendula March 2021 Mo Tu We Th Fr Sa Su ... -s, --sunday Sunday as first day of week -m, --monday Monday as first day of week --tuesday Tuesday as first day of week --wedn
FB Calculate Day Of Week.zip FB Day light savings function block.zip FB Extract Time Date into SecMin Hr Day Mth Yr.zip FB Scale with parameters.zip GKF1250离心机CXP.rar gkf1250离心机cxpgkf离心机omron...
Searching for Patterns in Trading by Day of Week Querying Two or More Tables with SQL Querying Multiple Tables with Subqueries Querying Multiple Tables with Joins Comparing Subqueries and Joins ...