C#学习笔记之——写一个能算出今天是今年第几天的方法
来源:互联网 发布:千方百计医药软件 编辑:程序博客网 时间:2024/06/10 02:56
代码如下
using System;namespace test{static class Method{public static int DayOfYear (int year, int month, int day){int dayT = 0;dayT = day;for (int i = 1; i < month; i++) {if (i == 2)dayT += IsBissextile (year) ? 29 : 28; else if (i % 2 == 0) dayT += (i <= 7) ? 30 : 31;else if(i % 2 == 1)dayT += (i <= 7) ? 31 : 30;elsethrow new IndexOutOfRangeException("1 <= month <= 12");}return dayT;}public static bool IsBissextile (int year){if (year % 4 == 0 && year % 100 == 0)return true;elsereturn false;}}class MainClass{public static void Main(string[] args){int a,b,c;Console.Write ("a=");a = int.Parse (Console.ReadLine ());while (a >= 0) {Console.Write ("b=");b = int.Parse (Console.ReadLine ());Console.Write ("c=");c = int.Parse (Console.ReadLine ());Console.WriteLine (Method.DayOfYear (a, b, c));Console.Write ("a=");a = int.Parse (Console.ReadLine ());}}}}
阅读全文
0 0
- C#学习笔记之——写一个能算出今天是今年第几天的方法
- Java之判断今天是今年的第几天!...
- 看看今天是今年的第几天
- 今天是今年的第几天
- 今天是今年的第几天问题
- 结构体输出今天是今年的第几天?
- java计算今天是今年的第几天
- 第十一周项目5今天是今年的第几天
- 判断今天是今年的第几天(1)
- 判断今天是今年的第几天(2)
- 输入某年某月某日,计算出今天是今年的第几天
- 今天写一个判断哪年哪月哪日是那年的第几天。。。。。
- 今年的第几天
- 今年的第几天
- 今天是第几天
- lwj_C#_输入年月日,写方法输出它是今年的第几天;
- date 今天是本周的第几天
- JS——计算某天是今年的第几天
- Leetcode 406. Queue Reconstruction by Height[Medium]
- Ashampoo Burning Studio 19(阿香婆光盘刻录软件)官方破解版V19.0.1.4下载
- 代理模式
- 风投与IT与中国
- iOS开发网络篇 一一 NSURLSessionDataTask实现大文件离线断点下载(重点)
- C#学习笔记之——写一个能算出今天是今年第几天的方法
- [JAVA]重载与重写的区别
- Java MySql简单使用
- 2370 小机房的树(lca)
- JAX-RS客户端WebClient的使用教程
- TRUNCATE命令
- 图片验证码(Struts2中使用)
- 【软工】开发模型
- values资源之styles