using System; using System.Collections.Generic; using System.Windows.Forms; using System.IO; namespace _3 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } List text = new List(); string st; private void button1_Click_1(object sender, EventArgs e) { StreamReader sr = new StreamReader(@"C:\Users\ilyae\OneDrive\Рабочий стол\test.txt"); while (!sr.EndOfStream) { st = sr.ReadLine(); listBox1.Items.Add(st); text.Add(st); } sr.Close(); Controls.Remove(button1); } private void button2_Click(object sender, EventArgs e) { Random rn = new Random(); for (int i = 0; i < listBox1.Items.Count; i++) { for (int j = i + 1; j < listBox1.Items.Count - 1; rn.Next(0, listBox1.Items.Count + 1)) { st = listBox1.Items[i].ToString(); listBox1.Items[i] = listBox1.Items[j]; listBox1.Items[j] = st; break; } } } int numb; private void button4_Click(object sender, EventArgs e) { Single x; if (Single.TryParse(textBox1.Text, out x) == false) MessageBox.Show("Введите целое число."); else { numb = int.Parse(textBox1.Text); if (numb > listBox1.Items.Count || numb <= 0 || numb == 1) MessageBox.Show("Введено неверное число."); else { numb -= 1; for (int i = numb - 1; ; i++) { for (int j = numb; ; j++) { st = listBox1.Items[i].ToString(); listBox1.Items[i] = listBox1.Items[j]; listBox1.Items[j] = st; break; } break; } } } textBox1.Clear(); } private void button3_Click(object sender, EventArgs e) { Single x; if (Single.TryParse(textBox1.Text, out x) == false) MessageBox.Show("Введите целое число."); else { numb = int.Parse(textBox1.Text); if (numb >= listBox1.Items.Count || numb <= 0) MessageBox.Show("Введено неверное число."); else { numb -= 1; for (int i = numb + 1; ; i++) { for (int j = numb; ; j++) { st = listBox1.Items[i].ToString(); listBox1.Items[i] = listBox1.Items[j]; listBox1.Items[j] = st; break; } break; } } } textBox1.Clear(); } private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { } int k = 0; private void button5_Click_1(object sender, EventArgs e) { for (int g = 0; g < text.Count; g++) { st = listBox1.Items[g].ToString(); if (text[g] != st) { MessageBox.Show("Расстановки строк не равны."); break; } else k++; } if (k == text.Count) MessageBox.Show("Расстановки строк равны."); } } }