201509-2 日期计算 Java
2024-08-31 06:47:06
思路:
每月有多少天是固定的,放到数组中,2月单独判断一下。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int y = sc.nextInt();
int d = sc.nextInt();
int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
if((y%4==0 && y%100!=0) || y%400 == 0) {
days[1] = 29;
}
int m = 0;
while(d > days[m]) {
d -= days[m];
m++;
}
System.out.println(m+1);
System.out.println(d);
}
}
最新文章
- 基于InstallShield2013LimitedEdition的安装包制作
- ASP.NET 画图与图像处理-生成高质量缩略图
- php 以IP的形式获取访问者的地理位置
- 字符串混淆技术在.NET程序保护中的应用及如何解密被混淆的字符串
- [R]R语言里的异常处理与错误控制
- [转]LUA元表
- iOS 8 界面设计 PSD 模板(iPhone 6),免费下载
- 简单几何(半平面交+二分) LA 3890 Most Distant Point from the Sea
- jsp页面指令
- Only one instance of a ScriptManager can be added to the page.
- CSS skills: 3) show sub-navigate items when mouse hove on nav-item
- 【转】 LINQ To SQL 语法及实例大全
- Android 滑动界面实现---Scroller类别 从源代码和开发文档了解(让你的移动布局)
- C# Async/await 异步多线程编程
- flask-script组件
- Apache Solr vs Elasticsearch
- 2019.03.09 codeforces620E. New Year Tree(线段树+状态压缩)
- 使用SQL查看表字段和字段说明
- Arch Linux中禁用UTC解决双系统时间问题
- file相关方法