Advertisement
ntamas

orai0317

Mar 17th, 2014
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.70 KB | None | 0 0
  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.Windows.Forms;
  9.  
  10. namespace WindowsFormsApplication1
  11. {
  12.   public partial class Form1 : Form
  13.   {
  14.     public Form1()
  15.     {
  16.       InitializeComponent();
  17.     }
  18.     private bool paritas(int a)
  19.     {
  20.       if (a % 2 == 0)
  21.       {
  22.         return true;
  23.       }
  24.       else
  25.       {
  26.         return false;
  27.       }
  28.     }
  29.     private void button1_Click(object sender, EventArgs e)
  30.     {
  31.       Random vel = new Random();
  32.       listBox1.Items.Clear();
  33.       int a = 0, b = 0;
  34.       int szamlal = 0;
  35.       int rand;
  36.       if (radioButton1.Checked)
  37.       {
  38.         b = 10;
  39.       }
  40.       if (radioButton2.Checked)
  41.       {
  42.         a = 10;
  43.         b = 100;
  44.       }
  45.       if (radioButton3.Checked)
  46.       {
  47.         a = 100;
  48.         b = 1000;
  49.       }
  50.       if (checkBox1.Checked && !checkBox2.Checked)
  51.       {
  52.         szamlal = 0;
  53.         do
  54.         {
  55.           rand = vel.Next(a, b);
  56.           if (paritas(rand))
  57.           {
  58.             listBox1.Items.Add(rand);
  59.             szamlal++;
  60.           }
  61.         } while (szamlal < 10);
  62.       }
  63.       else if (checkBox2.Checked && !checkBox1.Checked)
  64.       {
  65.         szamlal = 0;
  66.         do
  67.         {
  68.           rand = vel.Next(a, b);
  69.           if (!paritas(rand))
  70.           {
  71.             listBox1.Items.Add(rand);
  72.             szamlal++;
  73.           }
  74.         } while (szamlal < 10);
  75.       }
  76.       else if (checkBox1.Checked && checkBox2.Checked)
  77.       {
  78.         for (int i = 0; i < 10; i++)
  79.         {
  80.           listBox1.Items.Add(vel.Next(a, b));
  81.         }
  82.       }
  83.     }
  84.   }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement