选择月份选框
2月到8月
第一:算出2月到8月共有多少月
第二:列出2月到8月的所有月份求程序

解决方案 »

  1.   

    to 1int n = 8 - 2;
    or
    int n = 8 - 2 + 1;to 2
    for( int i = 2; i < 8 + 1; i++ )
       Console.WriteLine( string.Format( "{0}月", i ) );
      

  2.   

    static void Main(string[] args)
    {
        Compare(DateTime.Parse("2006-2-1"), DateTime.Parse("2006-8-1"));
        Console.Read();
    }public static void Compare(DateTime MonthStart, DateTime MonthEnd)
    {
        Console.Write(MonthStart.ToString("yyyy年MM月"));
        Console.Write("到");
        Console.Write(MonthEnd.ToString("yyyy年MM月"));
        Console.Write("共计");
        Console.WriteLine(((MonthEnd.Year - MonthStart.Year) * 12 + (MonthEnd.Month - MonthStart.Month)) + "个月");
        Console.WriteLine("分别是:");
        while (MonthStart.Month <= MonthEnd.Month || MonthStart.Year < MonthEnd.Year)
        {
            Console.WriteLine(MonthStart.ToString("yyyy年MM月"));
            MonthStart = MonthStart.AddMonths(1);
        }
    }
    //一次类推可以算出“年”“月”“日”“时”“分”“秒”
      

  3.   

    Dim t1, t2 As DateTime
            Dim t As Integer        t = (t2.Year - t1.Year) * 12 + t2.Month - t1.Month
      

  4.   

    Console.WriteLine("2月到8月共有6个月,他们是:2月,3月,4月,5月,6月,7月")
    好久没笑了,呵呵
      

  5.   

    Console.WriteLine("2月到8月共有6个月,他们是:2月,3月,4月,5月,6月,7月")
    好久没笑了,呵呵嘿嘿,果然高难度!!!!!!!!!!1111111
      

  6.   

    int nstart = 2;
                int nend = 8;
                int nSum = 0;            DateTime dts = new DateTime(2006, nstart, 1);
                DateTime dte = new DateTime((nend < nstart) ? 2007 : 2006, nend, 1);
                for (DateTime dt = dts; dt <= dte; dt = dt.AddMonths(1))
                {
                    nSum++;
                    Console.WriteLine(dt.Month);
                }
                Console.WriteLine(nSum);
      

  7.   

    呵呵,这个id就是那个自己说自己是“架构师”,但是薪水才2000多,还一本正经教训别人http://access911.net/getnews/doc1.asp?mode=a&aid=5019895
      

  8.   

    看到楼主一个有意思的帖子http://community.csdn.net/Expert/topic/5019/5019895.xml?temp=.9960138
      

  9.   

    Console.WriteLine("2月到8月共有6个月,他们是:2月,3月,4月,5月,6月,7月")
    好久没笑了,呵呵--------------------------
    厉害
      

  10.   

    Console.WriteLine("2月到8月共有6个月,他们是:2月,3月,4月,5月,6月,7月")
    好久没笑了,呵呵--------------------------
    厉害