Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsFormsApplication1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private bool paritas(int a)
- {
- if (a % 2 == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Random vel = new Random();
- listBox1.Items.Clear();
- int a = 0, b = 0;
- int szamlal = 0;
- int rand;
- if (radioButton1.Checked)
- {
- b = 10;
- }
- if (radioButton2.Checked)
- {
- a = 10;
- b = 100;
- }
- if (radioButton3.Checked)
- {
- a = 100;
- b = 1000;
- }
- if (checkBox1.Checked && !checkBox2.Checked)
- {
- szamlal = 0;
- do
- {
- rand = vel.Next(a, b);
- if (paritas(rand))
- {
- listBox1.Items.Add(rand);
- szamlal++;
- }
- } while (szamlal < 10);
- }
- else if (checkBox2.Checked && !checkBox1.Checked)
- {
- szamlal = 0;
- do
- {
- rand = vel.Next(a, b);
- if (!paritas(rand))
- {
- listBox1.Items.Add(rand);
- szamlal++;
- }
- } while (szamlal < 10);
- }
- else if (checkBox1.Checked && checkBox2.Checked)
- {
- for (int i = 0; i < 10; i++)
- {
- listBox1.Items.Add(vel.Next(a, b));
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement