黑马程序员之C#学习笔记: 判断该月份有几天
2012-11-14 20:54
483 查看
--------------------------------------------------- 2345王牌技术员联盟、2345王牌技术员联盟、期待与您交流!--------------------------------------------------------- 用户输入年份和月份 判断该月份有几天 该练习主要是练习同学们要掌握的知识点有:一:掌握闰年的判断 二:学会使用if多分枝条件判断结构 三: switch选择器的使用 那么该小程序的具体实现如下: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Test6 { calss Program { static void Main(string[] args) { Console.WriteLine("请输入一个年份:"); int Year = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("请输入一个月份:"); int Month = Convert.ToInt32(Console.ReadLine()); if ((Year % 400 == 0) || ((Year % 4 == 0) && (Year % 100 != 0))) { switch (Month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: Console.WriteLine("该月有31天"); break; case 2: Console.WriteLine("该月有29天"); break; default: Console.WriteLine("该月有30天"); break; } } else { switch (Month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: Console.WriteLine("该月有31天"); break; case 2: Console.WriteLine("该月有28天"); break; default: Console.WriteLine("该月有30天"); break; } } Console.ReadKey(); } } } --------------------------------------------------- 2345王牌技术员联盟、2345王牌技术员联盟、期待与您交流!--------------------------------------------------------- |
相关文章推荐
- 黑马程序员之C#编程基础学习笔记:提示用户输入密码,如果密码是“888888”,则提示正确,否则提示错误。
- 黑马程序员之C#编程基础学习笔记:有一个整数数组,请声明一个字符串数组,将整数数组中的每一个元素的值转换为字符串保存到字符串数组中
- 黑马程序员之c#学习笔记:如何理解C#中的指针
- 黑马程序员之 C#学习笔记:结构体是复制传递的经典案例
- 【转】.NET深入学习笔记(2):C#中判断空字符串的4种方法性能比较与分析
- 黑马程序员之ASP.NET学习笔记:.NET,ASP.NET,C#,VisualStudio之间的关系是什么?
- 黑马程序员 C#学习笔记④ 入门经典里的扑克牌游戏客户程序
- 黑马程序员--c#基础学习笔记2
- 黑马程序员之C#编程基础学习笔记:提示用户输入密码,如果密码是“888888”,则提示正确,否则要求再输入一次,如果密码是“888888”则提示正确,否则提示错误。
- 黑马程序员之C#编程基础学习笔记:将一个字符串数组的元素的顺序进行反转。
- 黑马程序员之c#学习笔记:C#中的方法的种类以及区别
- 黑马程序员之C#学习笔记: c#中重写(覆盖)和隐藏类的方法
- 黑马程序员之 MVC学习笔记:探讨MVC下登陆时根据身份判断
- 黑马程序员C#学习笔记
- 黑马程序员 C#学习笔记⑥ 三层架构基础实现员工信息管理
- 黑马程序员之C#学习笔记:关于继承
- 黑马程序员之C# 学习笔记:打包的简述
- 黑马程序员之C#编程基础学习笔记:提示用户输入用户名,然后再提示输入密码,如果用户名是"admin"并且密码是“888888”,则提示正确,否则提示错误,如果用户名不是admin还提示用户用户名不存在
- 黑马程序员之C#学习笔记:C#索引器与属性的区别、索引器的具体使用
- 黑马程序员之C#学习笔记:关于C#构造函数