zoukankan      html  css  js  c++  java
  • [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);
                    }
    
            }
        }
    }
    


     

  • 相关阅读:
    ListView 分页显示(转载+修改)下
    ListView 分页显示(转载+修改)上
    Android_开发片段(Part 1)
    JSCH执行linux命令
    linux运行wkhtmltopdf
    Apache HttpClient
    JDK自带的URLConnection
    java poi读取excel
    CXF webservice完整例子
    Oracle 常用初始化命令
  • 原文地址:https://www.cnblogs.com/sr1993/p/3697967.html
Copyright © 2011-2022 走看看