vb.net 交错 处理 一年中的月份天数的输出

前端之家收集整理的这篇文章主要介绍了vb.net 交错 处理 一年中的月份天数的输出前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

处理一年中的月份天数的输出

知识点 :

数组+交错

Module Module1

    Sub Main()
        Dim calendars()() As Double = New Double(11)() {}
        Dim month As Integer
        Dim days As Integer
        Dim dayValue,i As Integer
        For month = 0 To 11
            days = DateTime.DaysInMonth(Year(Now),month + 1)
            calendars(month) = New Double(days - 1) {}
            i = 0
            For Each dayValue In calendars(month)
                calendars(month)(i) = i + 1
                i += 1
            Next
        Next month


        For month = 0 To 11
            i = 0
            Console.WriteLine("{0}月",month + 1)
            For Each dayValue In calendars(month)
                Console.Write("  {0}",calendars(month)(i))
                i += 1
            Next
            Console.WriteLine()
        Next month



        Console.ReadLine()
    End Sub

End Module


运行效果

原文链接:https://www.f2er.com/vb/259421.html

猜你在找的VB相关文章