当前位置:网站首页>日期(DAY 76)
日期(DAY 76)
2022-07-25 06:01:00 【张学恒】
1:题目
今天是 2012 年 4 月 12 日星期四,编写程序,输入今天开始到 12 月 31 日之间的任意日期,输出那一天是星期几。
输入格式
共两行,第一行包含一个整数 m,表示询问日期的月份。
第二行包含一个整数 d,表示询问日期的为该月的第几天。
输出格式
输出询问日期是星期几。
注意,要用英文表示。
周一到周日的英文表示如下:
"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"
数据范围
4≤m≤12,
1≤d≤31,
保证日期合法。
输入样例:
5
20
输出样例:
Sunday
2:代码实现
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int months[] = {
0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
int main()
{
int month, date;
cin >> month >> date;
int m = 4, d = 12, day = 4;
while (m < month || d < date)
{
d ++ ;
if (d > months[m])
{
d = 1;
m ++ ;
}
day = (day + 1) % 7;
}
string names[] = {
"Sunday", "Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"
};
cout << names[day] << endl;
return 0;
}
边栏推荐
- NFT: how to improve rentable NFT (erc-4907)
- 同条网线电脑正常上网,手机连接wifi成功,但是无法访问互联网
- 新时代生产力工具——FlowUs 息流全方位评测
- 剖析kubernetes集群内部DNS解析原理
- Sword finger offer 32 - I. print binary tree from top to bottom
- Era5 dataset description
- Differences and application directions of GPS, base station and IP positioning
- 2021年ICPC陕西省赛热身赛 B.CODE(位运算)
- Blocking Queue Analysis
- R language uses rowmedians function to calculate the row data median value of all data rows in dataframe
猜你喜欢

What are the ways to realize web digital visualization?

(牛客多校二)J-Link with Arithmetic Progression(最小二乘法/三分)

HTB-Devel

基于ISO13209(OTX)实现EOL下线序列

Leetcode 202. happy number (not happy at all)

Sword finger offer 05. replace spaces
This is how the permission system is designed, yyds

Baidu, Alibaba, Tencent, who fell first?

Mechanism and principle of multihead attention and masked attention

sqlilabs less-28~less-8a
随机推荐
Ceres solver version 1.14 and eigen3.2.9
leetcode/ 前 n 个数字二进制中 1 的个数
2020icpc Jiangxi warm up e.robot sends red packets (DFS)
MATLAB作图实例:5:双轴图
同条网线电脑正常上网,手机连接wifi成功,但是无法访问互联网
Introduction summary of using unirx in unity
Softing pnGate系列网关:将PROFIBUS总线集成到PROFINET网络
Leetcode 204. count prime numbers (wonderful)
Unity accesses chartandgraph chart plug-in
(2022 Niuke multi School II) k-link with bracket sequence I (dynamic planning)
[ultra detailed diagram] FPN + mask RCNN
剖析kubernetes集群内部DNS解析原理
Calculate BDP value and wnd value
2021年ICPC陕西省赛热身赛 B.CODE(位运算)
context must be a dict rather解决
G1 garbage collector
(Niuke multi School II) j-link with arithmetic progress (least square method / three points)
(2022牛客多校)D-Link with Game Glitch(spfa)
(16)[系统调用]追踪系统调用(3环)
Leetcode/ binary addition