HW4.29
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the year: "); int year = input.nextInt(); System.out.print("Enter the weekday of the first day: "); int weekday = input.nextInt(); input.close(); String[] stringOfMonths = {"January", "February", "March", "April", "May", "June", "July", "August", "Sepetember", "October", "November", "December"}; int[] dayOfMonths = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) dayOfMonths[1]++; int count; for(int i = 0; i < 12; i++) { System.out.println(" " + stringOfMonths[i] + " " + year); System.out.println("-----------------------------------"); System.out.printf("%5s%5s%5s%5s%5s%5s%5s", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); System.out.println(); count = 0; for(int j = 0; j < weekday; j++) { System.out.printf("%5s", " "); count++; } for(int j = 1; j <= dayOfMonths[i]; j++) { System.out.printf("%5d", j); count++; if(count == 7) { count = 0; System.out.println(); } } weekday = (weekday + dayOfMonths[i]) % 7; System.out.println("\n\n"); } } }
HW4.29的更多相关文章
- IIC驱动移植在linux3.14.78上的实现和在linux2.6.29上实现对比(deep dive)
首先说明下为什么写这篇文章,网上有许多博客也是介绍I2C驱动在linux上移植的实现,但是笔者认为他们相当一部分没有分清所写的驱动时的驱动模型,是基于device tree, 还是基于传统的Platf ...
- CSharpGL(29)初步封装Texture和Framebuffer
+BIT祝威+悄悄在此留下版了个权的信息说: CSharpGL(29)初步封装Texture和Framebuffer +BIT祝威+悄悄在此留下版了个权的信息说: Texture和Framebuffe ...
- DM9000驱动移植在mini2440(linux2.6.29)和FS4412(linux3.14.78)上的实现(deep dive)篇一
关于dm9000的驱动移植分为两篇,第一篇在mini2440上实现,基于linux2.6.29,也成功在在6410上移植了一遍,和2440非常类似,第二篇在fs4412(Cortex A9)上实现,基 ...
- 【hihoCoder】1148:2月29日
问题:http://hihocoder.com/problemset/problem/1148 给定两个日期,计算这两个日期之间有多少个2月29日(包括起始日期). 思路: 1. 将问题转换成求两个日 ...
- 《Entity Framework 6 Recipes》中文翻译系列 (29) ------ 第五章 加载实体和导航属性之过滤预先加载的实体集合和修改外键关联
翻译的初衷以及为什么选择<Entity Framework 6 Recipes>来学习,请看本系列开篇 5-13 过滤预先加载的实体集合 问题 你想过滤预先加载的实体集合,另外,你想使用 ...
- 背水一战 Windows 10 (29) - 控件(文本类): RichTextBlock, RichTextBlockOverflow, RichEditBox
[源码下载] 背水一战 Windows 10 (29) - 控件(文本类): RichTextBlock, RichTextBlockOverflow, RichEditBox 作者:webabcd ...
- 搭建 Windows Server 2003 + IIS6.0 + FastCGI + PHP5.3.29 + MySQL5.5.38 + Memcached1.2.6
一.下载相关软件: 1.VC9运行库 即VISUAL C++ 2008 自PHP5.3.0开始,PHP提供VC2008编译版,需要安装VC++ 2008的运行库. [微软官方下载] http://ww ...
- 将形如:Oct 8, 2016 5:29:44 PM串转换成正常时间在真机上遇到的坑
将形如:Oct 8, 2016 5:29:44 PM串转换成正常时间在真机上遇到的坑 /** * 根据传入字符串 * * @param str 传入的日期字符串 形如:Oct 8, 2016 5:29 ...
- proxifier 3.29 key
Proxifier 3.29 serial key :- [Use only One ] (Standard Edition Keys) 5EZ8G-C3WL5-B56YG-SCXM9-6QZA ...
随机推荐
- greenlet代码解读
协程 上次已经讲解了协程的的实现方法,和我对协程的一些理解.这里指我就先以代码说明协程的运行.def test1(): print 12 (2) gr2.switch() ...
- 嵌入Web资源的方法
可以将js .图片.css等嵌入Assembly中,这样就不用将文件在aspx中写了,特别适合做自定义控件的时候将控件用到的资源打包. 将文件放到项目的合适路径,比如jpg文件所在路径的namespa ...
- C# Thread多线程学习
自我学习理解:一个程序中包括多个进程,每个进程包括多个线程,多个线程可同时做不同的事情(说是同时,但它是交换执行的,人感觉像是同时罢了). 优点:提高CPU的使用率. 线程同步:同步就是指一个线程要等 ...
- 解决修改SQL SERVER 默认1433端口 访问出错的问题;
1. 如何修改 数据库默认的 1433端口: SQL SERVER 配置管理器中 SQLSERVER 网络配置 xxx数据实例的协议中的 TCP/IP 中 默认端口 都修改为 自己定义的端口 例如 ...
- yii2源码学习笔记(十三)
模型类DynamicModel主要用于实现模型内的数据验证yii2\base\DynamicModel.php <?php /** * @link http://www.yiiframework ...
- php不允许用户提交空表单(php空值判断)
我们在设计提交空的评论时依然可以写入数据库,并在页面显示出来.这显然是不合理的,所以需要我们加入空值判断 可以修改代码,添加些判断: 复制代码代码如下: if(empty($_POST['name ...
- JBPM4中常用概念总结
1. 流程定义(Process Definition) 流程定义是记录在xml文件中的对流程的描述,它包含唯一的流程开始节点和多个流程功能节点,每个节点之间使用transition进行连接. P ...
- Makefile与shell脚本的区别
引用博客:Makefile与shell脚本区别 在Makefile可以调用shell脚本,但是Makefile和shell脚本是不同的.本文试着归纳一下Makefile和shell脚本的不同. 1.s ...
- python多重继承:
除了从一个父类继承外,Python允许从多个父类继承,称为多重继承. 多重继承的继承链就不是一棵树了,它像这样: class A(object): def __init__(self, a): pri ...
- js 正则 非负整数
Javascript 正则表达式 非负整数 /** * 正则判断非负整数 */ function testnum(ob){ var reg=/^[0-9]+?$/; //如果正则需要判断非负整数并带2 ...