Used with #
How to make randomization carried out in two ways?
Option 1: min = 1,000; max = 5,000; col = 1;
Option 2: min = 1; max = 20; col = 4;
The attached code could not be configured, so I would be grateful if someone would help to customize or offer their own version to solve this problem. Link to the project
reference to the project IZM1
How to download the project see ( http://prntscr.com/dmh2iw )
CODE
namespace rsh { public partial class Form1 : Form { public Form1() { InitializeComponent(); } Random r = new Random(); // РАНДОМИЗАЦИЯ ВАРИАНТ 1 private void button1_Click(object sender, EventArgs e) { int min = Convert.ToInt16(textBox1.Text); // МАКС - максимальное число диапазона int max = Convert.ToInt16(textBox2.Text); // МИН - минимальное число диапазона int col = Convert.ToInt16(textBox3.Text); // количество итераций int[] perm = Enumerable.Range(min, max + 1).ToArray(); for (int i = col; i >= 1; i--) { int j = r.Next(i + 1); // exchange perm[j] and perm[i]; int temp = perm[j]; perm[j] = perm[i]; perm[i] = temp; textBox4.AppendText(perm[i] + " " + "\r\n"); // выдаёт ОДИН ряд цифр } } // РАНДОМИЗАЦИЯ ВАРИАНТ 2 private void button3_Click(object sender, EventArgs e) { int min = Convert.ToInt16(textBox1.Text); // МАКС - максимальное число диапазона int max = Convert.ToInt16(textBox2.Text); // МИН - минимальное число диапазона int col = Convert.ToInt16(textBox3.Text); // количество итераций int[] perm = Enumerable.Range(min, max + 1).ToArray(); for (int i = col; i >= 1; i--) { int j = r.Next(i + 1); // exchange perm[j] and perm[i]; int temp = perm[j]; perm[j] = perm[i]; perm[i] = temp; textBox4.AppendText(perm[i] + " " + "\r\n"); // выдаёт ОДИН ряд цифр } } private void button2_Click(object sender, EventArgs e) { textBox4.Clear(); } } } 