A - Calendar
Description
According to the Gregorian calendar, which is the civil calendar in use today, years evenly divisible by 4 are leap years, with the exception of centurial years that are not evenly divisible by 400. Therefore, the years 1700, 1800, 1900 and 2100 are not leap
years, but 1600, 2000, and 2400 are leap years.
Given the number of days that have elapsed since January 1, 2000 A.D, your mission is to find the date and the day of the week.
Input
You may assume that the resulting date won’t be after the year 9999.
Output
Sample Input
1730
1740
1750
1751
-1
Sample Output
2004-09-26 Sunday
2004-10-06 Wednesday
2004-10-16 Saturday
2004-10-17 Sunday
#include <stdio.h>
#include<string.h>
#include<math.h> char week[7][10]={"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
int year[2]={365,366};
int month[2][12]={31,28,31,30,31,30,31,31,30,31,30,31,31,29,31,30,31,30,31,31,30,31,30,31};
int type(int m)
{
if(m%4!=0||(m%100==0&&m%400!=0))
return 0;
else return 1;
}
int main()
{
int days,dayofweek;
int i=0,j=0;
while(scanf("%d",&days)!=EOF&&days!=-1)
{
dayofweek=days%7;
for(i=2000;days>=year[type(i)];i++)
days-=year[type(i)];
for(j=0;days>=month[type(i)][j];j++)
days-=month[type(i)][j];
printf("%d-%02d-%02d %s\n",i,j+1,days+1,week[dayofweek]);
}
return 0;
}
A - Calendar的更多相关文章
- Java 时间类-Calendar、Date、LocalDate/LocalTime
1.Date 类 java.util.Date是一个"万能接口",它包含日期.时间,还有毫秒数,如果你只想用java.util.Date存储日期,或者只存储时间,那么,只有你知道哪 ...
- Js: Extensible Calendar Examples
http://ext.ensible.comhttps://github.com/bmoeskau/Extensiblehttps://github.com/TeamupCom/extensibleh ...
- Calendar类
Calendar类 注意:根据日历规则,如果想要这个月减去5天,那么则为: add(Calendar.Day,-5) 成员方法: public int get(int field):返回给定日历段的值 ...
- This month Calendar
package fourth;import java.text.DateFormatSymbols;import java.util.*;public class CalendarTest { pub ...
- calendar的一些操作
一.通过分析日期函数,根据日期进行一系列操作,例如:我们需要知道2个时间段中所有的日期等等. 由于Calendar 类是一个抽象类,因此我们不能通过new来获取该对象的实例.我们可以通过其类方法 ge ...
- java-String Date Calendar之间的转换
1.Calendar 转化 String Calendar calendat = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDa ...
- jQuery Ion.Calendar 日期/日历
在线实例 实例演示 默认 实例演示 每周第一天 实例演示 输入框插件 实例演示 HTML data 属性 实例演示 回调函数1 实例演示 回调函数2 使用方法 <div id="cal ...
- [java] 可视化日历的实现(基于Calendar类 )
写在前面 博文安排顺序如下 1.写在前面 2.源码 3.思路 4.相关知识 该小程序是对Date类及其相关类的复习 要求如下图:实现可视化日历 实现思路 1.先从键盘输入指定格式的字符串(str)2. ...
- WPF 点击Calendar后,需要点击两次按钮
主面板上有一个Calendar控件,点击选择了日期后,如果点击确认按钮,需要点击两次.这个问题的解决方法如下: private void calendar1_PreviewMouseUp(ob ...
- 【JAVA】JDK -Calendar 遇到的 一个坑
Calendar是JDK 1.1增加的类 最近使用了下Calendar发现几个很让人抓狂的问题 源码: public final static int SUNDAY = 1; public final ...
随机推荐
- 【VSCode】Windows下VSCode便携式c/c++环境
http://blog.csdn.net/c_duoduo/article/details/52083494 Ver 1.1 完整版(修复mingw环境变量错误)下载: http://pan.baid ...
- 【阿里巴巴Java开发手册——集合处理】13.集合的稳定性(order)和有序性(sort)
有序性(sort):指遍历的结果是按照某种比较规则依次排列的. 稳定性(order):指集合每次遍历的元素的次序是一定的. 如:ArrayList是order/unsort HashMap是unord ...
- Django-启动文件的制作
在Django项目下的app.py中写入这几行代码,当启动的时候会找项目下名为:stark.py的文件并先加载 #app.py from django.apps import AppConfig cl ...
- Android 网络知识必知必会
目录: 网络分层 TCP 和 UDP 区别 TCP 三次握手以及为什么需要三次握手 UDP 四次挥手以及为什么需要四次挥手 socket 开发相关 Http 是什么 Https 是什么以及和 HTTP ...
- 图灵数学·统计学丛书.PDF(53本全)
图灵数学·统计学丛书01-概率论及其应用(第1卷·第3版)-[美]William.Feller-人民邮电出版社.pdf 图灵数学·统计学丛书01-金融数学:衍生产品定价引论-[英]M·巴克斯特& ...
- 1. Tensorflow高效流水线Pipeline
1. Tensorflow高效流水线Pipeline 2. Tensorflow的数据处理中的Dataset和Iterator 3. Tensorflow生成TFRecord 4. Tensorflo ...
- java反编译工具(Java Decompiler)
1,下载地址,包括GUI,Eclipse插件 http://jd.benow.ca/ 2,Eclipse插件的安装参看 https://blog.csdn.net/yh_zeng2/article/d ...
- Java知多少(14)数组
如果希望保存一组有相同类型的数据,可以使用数组. 数组的定义和内存分配 Java 中定义数组的语法有两种: type arrayName[]; type[] arrayName; type 为Java ...
- Spark学习笔记——Spark上数据的获取、处理和准备
数据获得的方式多种多样,常用的公开数据集包括: 1.UCL机器学习知识库:包括近300个不同大小和类型的数据集,可用于分类.回归.聚类和推荐系统任务.数据集列表位于:http://archive.ic ...
- Scala学习笔记——断言和单元测试
1.断言 assert(conditon)将在条件不成立的时候,抛出assertionError assert(conditon,explanation)讲在条件不成立的时候,抛出explanatio ...