`
YuHuang.Neil
  • 浏览: 187730 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论
阅读更多
问题:
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
分享到:
评论

相关推荐

    FB Calculate Day Of Week.rar

    在本文中,我们将深入探讨欧母龙PLC(Omron PLC)编程中如何计算一周中的某一天,这个主题与提供的压缩文件"FB Calculate Day Of Week.rar"紧密相关。欧母龙PLC是一种广泛应用于自动化控制领域的可编程逻辑控制器,...

    Day of Week + Week Number + Auto BST adjustment.rar

    标题中的“Day of Week + Week Number + Auto BST adjustment”表明这个压缩包可能包含与编程相关的程序或配置,涉及到了时间日期处理以及自动调整夏令时(BST,British Summer Time)的逻辑。在工业自动化领域,如...

    Day of week.exe

    Day of week.exe

    Get the Day of Week that a Day Falls On

    标题“Get the Day of Week that a Day Falls On”暗示了一个编程任务,即获取特定日期是星期几。这个功能在各种应用程序中都很常见,比如日历应用或者时间管理工具。让我们深入探讨一下相关知识点。 首先,我们...

    Determining Day of Week

    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...

    day-of-week:星期几图书馆

    find by ISO-8601 numeric representation of day/** @var Day */$ today = Day :: getToday (); use Hrevert \ Day \ Day ;use Hrevert \ Day \ DayCollection ;$ days = new DayCollection ([

    Day of the week.rar

    本资料主要探讨的是AB PLC的程序设计与应用,通过“Day of the week.rar”这个压缩包,我们可以深入学习如何利用AB PLC实现对一周七天不同工况的控制。 首先,我们要了解AB PLC的基础架构。AB PLC通常包含处理器...

    java时间处理工具类--CalendarUtil(java源码)

    int last_day_of_week = first_day_of_week + 6; // 星期日 now.set(Calendar.DATE, last_day_of_week); return now.getTime(); } /** * 获得所在月份的最后一天 * @param 当前月份所在的时间 * @...

    java-leetcode题解之Day of the Week.java

    java java_leetcode题解之Day of the Week.java

    Just a Day - the Day of Week-crx插件

    语言:Deutsch,English,Nederlands,Türkçe,español,italiano,русский 工具栏的简单日期。 这只是一周的日子。 与刚刚的时钟扩展! 注意:当前版本可能在Windows的某些版本的Chrome上存在问题。...

    Cron表达式.docx

    - `L`:表示“最后”,在Day of Month中表示当月的最后一天,在Day of Week中表示当周的最后一天(通常是周六)。 - `W`:表示工作日(周一至周五),只在Day of Month中使用,会找到距离指定日期最近的工作日。 ...

    界面标准的JAVA日历记事本

    在得到日期的同时判断DAY OF WEEK星期几,在窗体上显示 5为各个按钮及标签添加监听 通过ActionPerform MousePressed实现其动作 6 保存日志 显示日志及删除日志,总过创建哈希表来进行文件的读写

    只是一天 - 每周的一天「Just a Day - the Day of Week」-crx插件

    工具栏的简单日期。这只是本周的一天。与JUST A CLOCK扩展配对! 注意:当前版本可能在某些版本的Windows版Chrome上存在问题。 进行修复; 挂紧 ========================-工具栏中的缩写星期几。...

    Php Date Picker - first day of week:Separd 网站的 PHP 日期选择器的修订版-开源

    此版本支持为一周的第一天不是星期一的国家/地区选择不同的第一天。 原始版本可以在 http://sourceforge.net/projects/phpdatepicker 找到它是在 GPL v3 下许可的,所以请随意使用和更改。

    Geodetic Toolbox

    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例程源码DayofWeek+WeekNumber+AutoBSTadjustment

    ABPLC例程源码Day of Week + Week Number + Auto BST adjustment本资源系百度网盘分享地址

    常用功能汇编语言代码汇总,例如:ASCII转换,浮点操作,网络,字符串,排序等

    常用功能汇编语言代码汇总,包括:ASCII 至 DWORD,RegWrite,RegReadStr,RegRead, Tokenizer,十六进制字符串转 DWORD,浮点操作,缓冲区对齐计算器,GetFeaturesFlags,Exists,Day of Week,从资源中提取文件,...

    mysql 关于详细时间应用

    使用MySQL Week, Week of Year, Day of Week, Weekday, YearWeek函数 - **WEEK()**: 返回一年中的第几周,默认情况下,一周的第一天为星期一。 - **WEEKOFYEAR()**: 同样返回一年中的第几周,但其计算方式略有不同...

    ESBPCS for VCL v6.20 Retail

    Calculator Edits, Calendar Edits, Button Edits, Degree/Minute/Second Edits, Comboboxes, Month Comboboxes, Day of Week Comboboxes, Time Zone Comboboxes, Country Comboboxes, Duration Comboboxes, ...

    Day-of-year-and-week.c.zip_This Is the Day

    (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...

Global site tag (gtag.js) - Google Analytics