[C#]数字颠倒输出;判断某天是一年中的第几天

数字颠倒输出:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 数字颠倒输出
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            String s = Console.ReadLine();
            n = int.Parse(s);
            while (n!=0)
            {
                Console.Write(n % 10);
                n /= 10;
            }
        }
    }
}


判断某天是一年中的第几天:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 第几天
{
    class Program
    {
        static void Main(string[] args)
        {
            int []num={0,31,29,31,30,31,30,31,31,30,31,30,31};
            int year,month,day;
            string temp=Console.ReadLine();
            year=int.Parse(temp);
            temp=Console.ReadLine();
            month=int.Parse(temp);
            temp=Console.ReadLine();
            int sum=0;
            day=int.Parse(temp);
                if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
                {
                    for (int i = month - 1; i >= 1; i--)
                        sum += num[i];
                    if (month >= 3)
                        sum--;
                    sum += day;
                    Console.WriteLine(sum);

                }
                else
                {
                    for (int i = month - 1; i >= 1; i--)
                        sum += num[i];
                    sum += day;
                    Console.WriteLine(sum);
                }

        }
    }
}


 

原文地址:https://www.cnblogs.com/sr1993/p/3697967.html