当前位置:网站首页>#25-1 OJ 78 Calculate birthday day of the week
#25-1 OJ 78 Calculate birthday day of the week
2022-08-09 14:47:00 【Ye Xiaobai】
题目描述

输入

输出

样例输入

样例输出

源代码
#include<stdio.h>
int main()
{
int year, month, day, allday;
int i, j;
while (scanf("%d %d %d", &year, &month, &day) != EOF)//Ensure input format requirements
{
allday = 0;
for (i = 1; i < year; i++)
{
if ((i % 4 == 0 && i % 100 != 0) || (i % 400 == 0))//判断闰年
{
allday += 366;
}
else
{
allday += 365;
}
}
for (i = 1; i < month; i++)
{
if (i == 2)//In judgment for2时是28还是29
{
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
{
allday += 29;
}
else
{
allday += 28;
}
}
else if (i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12)//Don't know could use an array of,I think it is more simple
{
allday += 31;
}
else
{
allday += 30;
}
}
allday += day;
j = allday % 7;
switch (j)//switchStatement judge week
{
case 0:printf("Sunday\n"); break;
case 1:printf("Monday\n"); break;
case 2:printf("Tuesday\n"); break;
case 3:printf("Wednesday\n"); break;
case 4:printf("Thursday\n"); break;
case 5:printf("Friday\n"); break;
case 6:printf("Saturday\n"); break;
}
}
return 0;
}
关于这题

边栏推荐
- ELK部署
- 12. cuBLAS Development Guide Chinese version--Level-1 functions asum() and axpy() in cuBLAS
- 使用 NVIDIA Kaolin Wisp 重建3D场景
- vs how to use a Button to link to another page
- C语言 函数问题
- 测试研发的人数科学比例
- 使用Connection对象连接管理事务
- 汇编语言学习(二)
- C语言 猜数字游戏 (含代码并详细注释)
- Jetpack Compose - simply the basic attributes of Modifier is introduced
猜你喜欢

响应式pbootcms模板建材家居类网站

Three kinds of ThreadLocal, play with thread variable storage and transmission

SEATA分布式事务框架解析

C语言中的 递归问题 以及将递归改写成非递归。(解析常见的几个递归题目及代码) 求阶乘、求斐波那契、汉诺塔、

*4-1 CCF 2014-12-1门禁系统

去IOE-EBS何去何从

使用 NVIDIA Kaolin Wisp 重建3D场景

汇编语言学习(二)

Using the NVIDIA Kaolin Wisp reconstruction of 3 d scene

小程序制作软件哪个好用?如何选择?
随机推荐
(PC+WAP)带手机端pbootcms模板农业种植类网站
救火队员的行为准则
汇编语言学习(七)
如何用vs新建Asp.net项目(Web页面)
Flex for openharmony container components
小程序模板制作流程,小程序模板制作方便快捷
*1-3 OJ 291 老鼠与猫的交易
word编号和文本间距过大
蓝桥杯嵌入式(STM32F103RBT6)最全攻略(一)
现实版商战:“武功再高,也怕菜刀”
零基础学习CANoe Panel 设计目录
Firewalld防火墙基础
Dry+Bean+Dataset R language data analysis, report in English
Row of openharmony container components
ensp如何正确配置静态路由
汇编语言学习(九)
阿里云PAI与香港大学合作论文入选INFOCOM 2022,有效减少大规模神经网络训练时间
汇编语言学习(六)课程设计一
预约直播 I 阿里云EMR StarRocks 产品发布会
RHCE课程总结