View difference between Paste ID: ewRWVmsk and qMm1gbQP
SHOW: | | - or go back to the newest paste.
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 Form7 : Form
13
    {
14
        public Form7()
15
        {
16
            InitializeComponent();
17
        }
18
19
        private void button1_Click(object sender, EventArgs e)
20
        {
21
            //Объявление массивов и переменных для выполнения задания;
22
            Random rnd = new Random();
23
            int[] arr = new int[10];
24
            label1.Text = String.Empty;
25
            //Начало цикла заполнения массива;
26
            for (int i = 0; i < 10; i++)
27
            {
28
                arr[i] = rnd.Next(10, 50);
29
                for (int j = 0; j < 10; j++)
30
                {
31
                    do
32
                    {
33
                        if (arr[i] == arr[j])
34
                        {
35
                            arr[i] = rnd.Next(10, 50);
36
                            j = 0;
37
                        }
38-
                        else j--;
38+
                        else j++;
39
                    } while (j < 10);
40
                    
41
                }
42
                    
43
                
44
45
                    //Вывод массива на форму;
46
                label1.Text += Convert.ToString(arr[i]) + ",";
47
               }
48
            }
49
50
                
51
            
52
53
                
54
55
            }
56
        }