多语言展示
当前在线:272今日阅读:2今日分享:38

用Visual Studio判断闰年和非闰年

实用于Visual Studio的出学者。
工具/原料
1

Visual Studio软件

2

电脑

方法/步骤
1

打开Visual Studio,选择新建项目。

3

代码  int year;            for (int i = 0; i < 6; i++)            {                Console.Write('请输入年份: ');                year = int.Parse(Console.ReadLine());                if (year % 4 == 0)                {                    if (year % 100 == 0)                    {                        if (year % 400 == 0)                            Console.WriteLine('{0}年是闰年! ', year);                        else                            Console.WriteLine('{0}年不是闰年! ', year);                    }                    else                    {                        Console.WriteLine('{0}年是闰年! ', year);                    }                }                else                {                    Console.WriteLine('{0}年不是闰年! ', year);                }                Console.ReadLine();

注意事项

所有标点符号皆为英文状态下

推荐信息