C#求该日期是这一年中的第几天
2014-09-04 17:31
120 查看
设计一个程序,输入一个日期,求该日期是这一年中的第几天。
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int years, moth, day,sum=0; int[] monthDays = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; years = int.Parse(Console.ReadLine()); moth = int.Parse(Console.ReadLine()); day = int.Parse(Console.ReadLine()); if (years % 400 == 0 || (years % 100 == 0 && years % 4 != 0)) { monthDays[1] = 29; } Console.Write("该天是该年的第"); for (int i = 0; i < moth; i++) { sum += monthDays[i]; } Console.Write(sum + day); Console.WriteLine("天。"); Console.ReadLine(); } } }
相关文章推荐
- C#8—写一个测试标准身高体重的程序、输入日期年月日, 计算这一天是一年中的第几天(考虑闰年)
- C#中怎么取到当前日期是在一年中的第几周
- C#关于日期月天数和一年有多少周及某年某周时间段的计算
- 判断所输入日期是一年中的第几天
- 计算日期是一年中的第几天(不用函数)
- 计算日期是一年中的第几天
- 用C编程计算某日期是一年中第几天
- C#关于日期月天数和一年有多少周及某年某周时间段的计算
- c# 获取某天是一年中的第几天
- 用C语言来实现_输入一个日期(年月日),计算是这一年中的第几天
- 用C++实现,输入一个日期,输出它是一年中的第几天。
- C#关于日期月天数和一年有多少周及某年某周时间段的计算
- C#计算当前日期是一年中的第几周
- C#中怎么计算当前日期是在一年中的第几周
- C#--第2周实验--任务9--编写一个控制台应用--输入一个日期,求该日期是这一年中的第几天
- C#中取到当前日期是在一年中的第几周
- C#关于日期月天数和一年有多少周及某年某周时间段的计算
- C# 取当天是一年中的第几季度,第几月,是该季度的第几天
- C#关于日期月天数和一年有多少周及某年某周时间段的计算
- Java 获得指定日期是一年中的第几天