Facebook
From Flying Dolphin, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 207
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApp23
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void button1_Click(object sender, EventArgs e)
  21.         {
  22.             int rok = int.Parse(t1.Text);
  23.             bool czydzieli4 = (rok % 4) == 0;
  24.             bool czydzieli100 = (rok % 100) == 0;
  25.             bool czydzieli400 = (rok % 400) == 0;
  26.  
  27.             bool czydzieli2000 = (rok % 2000) == 0;
  28.             if(czydzieli2000)
  29.             {
  30.                 MessageBox.Show("to rok przestępny");
  31.             }
  32.             else if (czydzieli4 == true &&
  33.                 czydzieli100 == false ||
  34.                 czydzieli400)
  35.             {
  36.                 MessageBox.Show("to rok przestępny");
  37.             }
  38.             else
  39.             {
  40.                 MessageBox.Show("To nie jest rok przestępny");
  41.             }
  42.         }
  43.     }
  44. }