首页 > 试题广场 >

Day of Week

[编程题]Day of Week
  • 热度指数:23188 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
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 2005, 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.

Month and Week name in Input/Output:
January, February, March, April, May, June, July, August, September, October, November, December
Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
示例1

输入

9 October 2001
14 October 2001

输出

Tuesday
Sunday
头像 FredaLiu
发表于 2020-03-02 14:38:45
这个题就是考察蔡勒公式。 W=[C/4]-2C+y+[y/4]+[26(m+1)/10]+d-1 (其中[ ]为取整符号)注意:1、 C是年份的前两位数 y是年份的后两位数 m是月份 d是日2、需要注意的是如果月份是一月二月,则需看成是上一年的13月,14月,所以月份不是1- 展开全文
头像 cxbatman
发表于 2022-03-15 23:10:57
主要是各块功能分好,解题就很简单了,一个一个功能做 #include<cstdio> #include<iostream> #include<string> using namespace std; int daytable[2][13]={ {0, 展开全文
头像 渺小小螃蟹
发表于 2021-05-08 13:41:27
include<stdio.h> include<stdbool.h> include <string.h> int daytab[2][13] ={ {0,31,28,31,30,31,30,31,31,30,31,30,31}, {0,31,29, 展开全文
头像 BrianWu
发表于 2021-07-07 10:52:30
简洁做法 /*描述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 divisibl 展开全文
头像 YokiN0
发表于 2022-10-13 09:10:06
求一个日期是星期几,转化为求它与1年1月1日的天数差。因为1年1月1日是星期一。
头像 牛客861440576号
发表于 2023-02-08 17:13:48
#include <cstdio> #include "string" #include "map" // 引入map using namespace std; // c++ 标准 /* 输入: 9 October 2001 14 October 2001 输出: Tuesd 展开全文
头像 夜奏花
发表于 2022-06-22 11:40:10
法一:硬算 暴力 #include <bits/stdc++.h> using namespace std; int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; string mmon[13]={"","January","Febr 展开全文
头像 普罗列塔丽亚
发表于 2021-12-30 13:00:20
查万年历,2001年1月1日是星期1,然后计算偏移即可 #include<stdio.h> #include<stdlib.h> #include<string.h> bool IsLeapYear(int year){ return&nb 展开全文
头像 土尔逊Torson
发表于 2023-03-31 13:24:37
//土尔逊Torson 编写于2023/3/31 #define _CRT_SECURE_NO_WARNINGS #include <map> #include <cstdio> #include <string> using namespace std; int 展开全文
头像 rainman_
发表于 2023-02-23 20:23:37
#include <iostream> #include <cstdio> #include <string> #include <map> using namespace std; int main() { //数字与星期几的映射 展开全文

问题信息

难度:
88条回答 11947浏览

热门推荐

通过挑战的用户

查看代码
Day of Week