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 _20140407
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private bool paritas(int szam)
- {
- if (szam % 2 == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if(textBox1.Text != "" && textBox2.Text != "")
- {
- int min, max, rnd, db = 0, cs;
- min = Convert.ToInt32(textBox1.Text);
- max = Convert.ToInt32(textBox2.Text);
- if (min > max)
- {
- cs = min;
- min = max;
- max = cs;
- }
- Random vel = new Random();
- listBox1.Items.Clear();
- db = 0;
- if (checkBox1.Checked && checkBox2.Checked)
- {
- for (int i = 0; i < 10; i++)
- {
- rnd = vel.Next(min, max + 1);
- listBox1.Items.Add(rnd);
- }
- }
- else if (checkBox1.Checked && !checkBox2.Checked)
- {
- do
- {
- rnd = vel.Next(min, max + 1);
- if(paritas(rnd))
- {
- listBox1.Items.Add(rnd);
- db++;
- }
- }while(db < 10);
- }
- else if (!checkBox1.Checked && checkBox2.Checked)
- {
- do
- {
- rnd = vel.Next(min, max + 1);
- if (!paritas(rnd))
- {
- listBox1.Items.Add(rnd);
- db++;
- }
- } while (db < 10);
- }
- }
- }
- private void duplaklikk(object sender, EventArgs e)
- {
- listBox1.Items.Remove(listBox1.SelectedItem);
- }
- private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement