• 日历输出


    private static void Main()
           {
               
               var cur = System.DateTime.Now;
     
     
               for (var i = 0; i < 12; i++)
               {
                   pp(cur.AddMonths(i), 0);
     
                   Console.WriteLine("*********************************************************");
               }
                
           }
     
     
           private static void pp(DateTime now, int offset)
           {
               var current = now.AddMonths(offset);
     
               var curMoth = current.Month;
     
               var curYear = current.Year;
     
               var calendarbegin = new DateTime(curYear, curMoth, 1);
               var calendarend = calendarbegin.AddMonths(1).AddDays(-1);
     
               var listd = new List<int>();
     
               int week1 = (int)calendarbegin.DayOfWeek;//获取当年当月1号的星期
               if (week1 > 0)
               {
                   calendarbegin = calendarbegin.AddDays(-week1);
               }
     
               int week30 = (int)calendarend.DayOfWeek;
     
               if (week30 < 6)
               {
                   calendarend = calendarend.AddDays(6 - week30);
               }
     
     
               var days = (calendarend - calendarbegin).Days + 1;
     
               Console.WriteLine(now.ToString() + "=>" + days);
     
               Console.WriteLine("日	一	二	三	四	五	六	");
     
               for (int i = 0; i < days; i++)
               {
                   if (i % 7 == 0)
                       Console.WriteLine();
     
                   var output = calendarbegin.AddDays(i);
                   string format = "{0}";
                   if (output.Month != curMoth)
                   {
                       format = "({0})";
                   }
     
                   Console.Write(string.Format(format, calendarbegin.AddDays(i).Day) + "	");
               }
     
               Console.WriteLine();
           }
  • 相关阅读:
    NOI2007项链工厂——sbTreap代码
    终于还是卡着进队了
    SCOI RP+=INF
    每日算法——新型在线LCA
    每日算法——并查集的应用
    每日算法--矩阵乘法优化递推
    神一般的数据结构--可持久化treap
    算法竞赛中的数论经典定理
    Baby Step Gaint Step
    素数分组 哥德巴赫猜想
  • 原文地址:https://www.cnblogs.com/zbw911/p/3647079.html
Copyright © 2020-2023  润新知