• 类型--2014年10月19日


    // //Console.WriteLine();

               // //int s = int.Parse(Console.ReadLine());

               // double d = double.Parse(Console.ReadLine());

               // //d=Math.Sqrt(d);//平方根,即25时,输出为5,,,输入4,0时输出2

               // // d=Math.PI;//圆周率

               // //d = Math.Ceiling(d);//取上线。即2.1为3.。。。。1.0为1

               // //d = Math.Floor(d);//去下线。即2.1为2,,,,,1.0为1

               ////d = Math.Round(d);//四舍五入,即2.4为2.。。2.5为2......偶数.5=偶数 奇数.5=奇数   4.5=4。。。。6.5=6。。。7.5=8。。。。。

                //DateTime s = new DateTime(1999, 3, 3, 3, 3, 3);//输入时间为:1999/3/3 3:03:03

                //DateTime s = DateTime.Now;//显示电脑上的时间表示方式,年月日时分秒   DateTime dt = new DateTime(); 

    dt = DateTime.Now; 时间表示和上面的一样

               

                DateTime dt = new DateTime();//初始化默认时间为0001年1月1日  00:00:00

                dt = DateTime.Now;//获取电脑上的本地时间     dt

                //int a = dt.Year;//获取年份                   a

                //int c = dt.DayOfYear;//一年的第几天           c

                //DayOfWeek w = dt.DayOfWeek;//获取今天是周几,若果今天是周日,是Sunday           w

     

    string s = Console.ReadLine();
    DateTime dt = new DateTime();//初始化默认时间为0001年1月1日  00:00:00
    dt = DateTime.Parse(s);
    s = dt.ToString("yyyy是个好年MM月dd日 hh时mm分ss秒");//yyyy代表年,MM代表月,dd代表日,hh,mm,ss,时,分,秒    这就是代位符,如hh,mm,yyyy等等           
     Console.WriteLine(s);
     Console.ReadLine();
    
    
    string s = Console.ReadLine();
     DateTime dt = new DateTime();//初始化默认时间为0001年1月1日  00:00:00
    dt = DateTime.Parse(s);
     System.TimeSpan time = new TimeSpan(3,3,20);//后面可以输入天。时,分,秒,毫秒
      dt=dt.Add(time);//从电脑上录入一个时间,在加上3小时3分20秒
     Console.WriteLine(dt);
    
    
    
    string s = Console.ReadLine();
     DateTime dt = new DateTime();//初始化默认时间为0001年1月1日  00:00:00
     dt = DateTime.Parse(s);
    System.TimeSpan time = new TimeSpan();
                dt=dt.Add(time);
                dt = dt.AddDays(1.2);//加上1.2天,参数为double
                dt = dt.AddHours(1.2);//加上1.2个小时,参数为double
                dt = dt.AddMonths(2);//加上2个月,参数为int,不能写成小数,如果原本是1月31号,然后加1,是2月29号,不会超额,如果是2014年12月31号时,就是2015年1月31号
                dt = dt.AddYears(1);//加上1年,参数为int,如果是2012年2月29号,,,,加上1年变成了2013年2月28号。闰年不闰年
                Console.WriteLine(dt);
    
                Console.ReadLine();
    
    ////判断您输入的年份是闰年还是平年
                //Console.Write("输入一个年份:");
                //int s = int.Parse(Console.ReadLine());
    
                //if (s % 100== 0)
                //{
                //   if(s%400==0)
                //       Console.WriteLine("您输入的年份是闰年,有366天");
                //    else
                //        Console.WriteLine("您输入的年份是平年,有365天");
                //}
                //else if(s%4==0)
                //{
                //    Console.WriteLine("您输入的年份是闰年,有366天");
                //}
                //else
                //    Console.WriteLine("您输入的年份是平年,有365天");
                //Console.ReadKey();
    
                //输入年份,判断是不是闰年()
                int year = 0;
                try
                {
                    year = int.Parse(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.Write("输入错误!");
                }
                finally
                {
                    if (0 < year && year <= 9999)
                    {
                        if (year % 100 == 0)
                        {
                            if (year % 400 == 0)
                            {
                                Console.Write("是闰年");
                            }
                            else
                            {
                                Console.Write("不是闰年");
                            }
                        }
                        else
                        {
                            if (year % 4 == 0)
                            {
                                Console.Write("是闰年");
                            }
                            else
                            {
                                Console.Write("不是闰年");
                            }
                        }
    
                    }
                    else
                    {
                        Console.Write("输入数字超出范围!");
                    }
                }
                Console.ReadKey();
    
    
    
    
    
                ////判断年月日是否输入正确两种做法
                //Console.WriteLine("输入年份");
                //int nian = int.Parse(Console.ReadLine());
                //Console.WriteLine("输入月份");
                //int yue = int.Parse(Console.ReadLine());
                //Console.WriteLine("输入日");
                //int ri = int.Parse(Console.ReadLine());
    
                ////判断年份输入的是否正确
                //if (nian <= 9999 && nian >= 0)
                //{
                //    Console.WriteLine("您输入年份正确");
                //}
                //else
                //{
                //    Console.WriteLine("您输入的年份错误");
                //}
    
                ////判断月份是否输入正确
                //if (yue <= 12 && yue >= 1)
                //{
                //    Console.WriteLine("您输入的月份正确");
                //}
                //else
                //{
                //    Console.WriteLine("您输入的月份错误,一年共十二个月");
                //}
    
                ////判断天是否输入正确
                //if (yue == 4 || yue == 6 || yue == 9 || yue == 11)
                //{
                //    if (ri >= 1 && ri <= 30)
                //        Console.WriteLine("您输入的日期正确");
                //    else
                //        Console.WriteLine("您输入的日期不正确");
                //}
                //else if (yue == 2)
                //{
                //    if (nian % 4 == 0)
                //    {
                //        if (ri >= 1 && ri <= 29)
                //            Console.WriteLine("您输入的天数正确");
                //        else
                //            Console.WriteLine("您输入的天数不正确,闰年的二月是29天");
                //    }
                //    else
                //    {
                //        if (ri >= 1 && ri <= 28)
                //            Console.WriteLine("您输入的天数正确");
                //        else
                //            Console.WriteLine("您输入的天数不正确,平年的2月时28天");
                //    }
                //}
                //else
                //{
                //    if (ri >= 1 && ri <= 31)
                //        Console.WriteLine("您输入的天数正确");
                //    else
                //        Console.WriteLine("您输入的天数不正确");
                //}
    
                //Console.WriteLine("您输入的是{0}年{1}月{2}日", nian, yue, ri);
                //Console.Read();
    
                //DateTime dt=new DateTime ();
                //int i=0;
                //try
                //{
                //dt=DateTime.Parse(Console.ReadLine());
                //}
    
    
                ////判断年月日是否输入正确(二种)
                //DateTime dt = new DateTime();
                //int i = 0;
                //try
                //{
                //    dt = DateTime.Parse(Console.ReadLine());
                //}
                //catch (Exception e)
                //{
                //    Console.Write("输入错误!");
                //    i++;
                //}
                //finally
                //{
                //    if (i == 0)
                //    {
                //        Console.Write("输入正确");
                //    }
                //}
                //Console.ReadKey();
    
    
    
    
    
    
    
    
    
                ////随机生成4位验证码,并输入对比是否正确两种做法
                //第一种
                //Console.WriteLine("输入四位验证码");
                //string a=Console.ReadLine();
                //string s = "abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                //    string show="";
               // Random re=new Random();
    
                //for (int i = 1; i <= 4;i++)
                //{
                //    int n = re.Next(s.Length);
                //    show = s.Substring(n, 1) + show;
    
                //}
                //Console.WriteLine(show);
                //if (a == show)
                //    Console.WriteLine("输出的正确");
                //else
                //    Console.WriteLine("输出的不正确");
                
                //Console.ReadKey();
    
    
               // //第二种做法
               ////随机生成4位验证码,并输入比对是否输入正确
               // string s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_";
               // Random r = new Random();
               // int zi1 = r.Next(63);
               // int zi2 = r.Next(63);
               // int zi3 = r.Next(63);
               // int zi4 = r.Next(63);
               // string a = s.Substring(zi1,1);
               // string b = s.Substring(zi2, 1);
               // string c = s.Substring(zi3, 1);
               // string d = s.Substring(zi4, 1);
    
               // string suiji = a+b+c+d;
               // Console.WriteLine(suiji);
                
               // while (true)
               // {
               //     string shuru = Console.ReadLine();
               //     shuru = shuru.ToUpper();
               //     suiji = suiji.ToUpper();
               //     if (shuru == suiji)
               //     {
               //         Console.Write("输入正确");
               //         break;
               //     }
               //     else
               //     {
               //         Console.Write("重新输入");
               //     }
               // }
       
               // Console.ReadLine();
    
    
    
                ////输入两个日期,求时间差多少天,具体到天就行
                ////写1023/1/3对,写1023.1.3也对
                //DateTime dt1 = new DateTime();
                //DateTime dt2 = new DateTime();
                //int i = 0;
                //int sum = 0;
                //try
                //{
                //    dt1 = DateTime.Parse(Console.ReadLine());
                //    dt2 = DateTime.Parse(Console.ReadLine());
                //}
                //catch (Exception e)
                //{
                //    Console.Write("输入错误!");
                //    i++;
                //}
                //finally
                //{
                //    if (i == 0)
                //    {
                //        if (dt1 > dt2)
                //        {
                //            //等量代换
                //            DateTime dt3 = dt2;
                //            dt2 = dt1;
                //            dt1 = dt3;
                //        }
                //        for (int k = dt1.Year; k < dt2.Year; k++)
                //        {
                //            if (k % 100 == 0)
                //            {
                //                if (k % 400 == 0)
                //                {
                //                    Console.Write(k + "是闰年");
                //                    sum += 366;
                //                }
                //                else
                //                {
                //                    Console.Write(k + "不是闰年");
                //                    sum += 365;
                //                }
                //            }
                //            else
                //            {
                //                if (k % 4 == 0)
                //                {
                //                    Console.Write(k + "是闰年");
                //                    sum += 366;
                //                }
                //                else
                //                {
                //                    Console.Write(k + "不是闰年");
                //                    sum += 365;
                //                }
    
                //            }
                //        }
                //        sum += dt2.DayOfYear - dt1.DayOfYear;
                //        Console.WriteLine("相差" + sum + "天");
                //    }
                //}
                //Console.ReadLine();
          
                ////控制台取当前电脑时间,之后输入一个天数,将当前电脑时间加上这个天数,输出时星期几
    
                //DateTime dt = new DateTime();//初始化默认时间为0001年1月1日  00:00:00
                //dt = DateTime.Now;//获取电脑上的本地时间 
                //Console.WriteLine("在这里输入一个天数");
                //int t = int.Parse(Console.ReadLine());
                //dt = dt.AddDays(t);
                //DayOfWeek w = dt.DayOfWeek;
                //Console.WriteLine(w);
                //Console.ReadKey();
    
                ////判断邮箱是否正确
                //Console.WriteLine("请输入邮箱");
                //string email = Console.ReadLine();
                //string em = email.Trim();
                //string em1 = email.ToLower();
                //string s = "aqwertyuioplmkjnhbgvcfdxzsaQAZWSXEDCRFVTGBYHNUJMKIOLP1234567890_@.";
                //int i=0;
                //for (; i < em.Length; i++)
                //{ 
                //    if(!(s.Contains(em.Substring(i,1))))
                //    {
                //    Console.WriteLine("含有非法字符")
                //        break;
                //    }
                //}
                //if(i==em.Length)
                //{
                //int a=em.IndexOf("@");
                //    int b=em.LastIndexOf("@");
                //    int c=em.IndexOf(".");
                //    int d=em.LastIndexOf(".");
    
                //}
    
  • 相关阅读:
    hive报错 java.sql.SQLException: No suitable driver found for jdbc:hive://localhost:10000/default
    使用Beeline连接Hive
    hive报错 root is not allowed to impersonate root (state=08S01,code=0)
    hive报错 Could not open client transport with JDBC Uri: jdbc:hive2://node01:10000/default:java.net.ConnectException refused
    excel快速删除空值单元格,数据上移
    FineBI 图表选择
    数据库连接池大小设置?
    工作中有待留❤️积累的一些经验
    内存包括随机存储器(RAM),只读存储器(ROM),以及高速缓存(CACHE)。RAM最重要
    我自己ood的复习思路:抄
  • 原文地址:https://www.cnblogs.com/9999w/p/4035036.html
Copyright © 2020-2023  润新知