Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.                 for (int j = 0; j < 10; j++)
  29.                 {
  30.                     if (arr[i] == arr[j])
  31.                         {
  32.                             arr[i] = rnd.Next(10, 50);
  33.                             j = 0;
  34.                         }
  35.                         else j++;
  36.                     if (j == arr.Length)
  37.                     {
  38.                         arr[i] = rnd.Next(10, 50);
  39.                     }
  40.                     if (i == arr.Length)
  41.                     {
  42.                         //Вывод массива на форму;
  43.                         label1.Text += Convert.ToString(arr[i]) + ",";
  44.                     }
  45.                 }
  46.                    
  47.                
  48.                }
  49.             }
  50.  
  51.                
  52.            
  53.  
  54.                
  55.  
  56.             }
  57.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement