1. 程式人生 > >C#程式碼判斷閏年

C#程式碼判斷閏年

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _02判斷閏年
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            int year = int.Parse(textBox1.Text);
            int i = year % 4;
            int j = year % 400;
            if (i==0 || j==0)
            {
                label2.Text = year.ToString() + "是閏年";
            }
            else
            {
                label2.Text = year.ToString() + "是平年";
            }
        }
    }
}