该日期是该年第几天

来源:互联网 发布:jsp 收费系统 源码 编辑:程序博客网 时间:2024/05/01 14:08
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{    class Program    {        static void Main(string[] args)        {            int year, month, day, sum=0;            int[] monthdays = {31,28,31,30,31,30,31,31,30,31,30,31};            year = int.Parse(Console.ReadLine());            month = int.Parse(Console.ReadLine());            day = int.Parse(Console.ReadLine());            if (year% 4 == 0 && year% 100 != 0 || year% 400==0)            {                 monthdays[1] = 29;            }            Console.Write("该天是该年的第");            for (int i = 0; i < month; i++)            {                 sum += monthdays[i];            }            Console.Write(sum+day);            Console.WriteLine("天!");            Console.ReadLine();        }    }}

心得体会:为什么输入数据时一定要换行啊?疑问

0 0
原创粉丝点击