Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.06 KB | None | 0 0
  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 quicksort_test
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public Form1()
  15.         {
  16.             InitializeComponent();
  17.         }
  18.  
  19.         int r = 20;
  20.         int[] container = new int[20];
  21.  
  22.         private void button1_Click(object sender, EventArgs e)
  23.         {
  24.             listBox1.Items.Clear();
  25.  
  26.             for (int i = 0; i < r; i++)
  27.             {
  28.                 listBox1.Items.Add(Modnar.willekeurig());
  29.             }
  30.         }
  31.  
  32.         private void button2_Click(object sender, EventArgs e)
  33.         {
  34.  
  35.  
  36.  
  37.             // the items in array container will be divided in two arrays,
  38.             // and in those arrays they will be divided again in two arrays
  39.  
  40.             int[] klein;
  41.             int[] groot;        
  42.             int kk = 0;
  43.            
  44.  
  45.            
  46.  
  47.  
  48.             container = new int[listBox1.Items.Count];
  49.  
  50.             for (int i = 0; i < container.Length; i++)
  51.             {
  52.                 container[i] = Convert.ToInt32(listBox1.Items[i]);
  53.             }
  54.             int gemiddelde = container.Sum() / container.Length;
  55.             for (int j = 0; j < container.Length; j++)
  56.             {
  57.                 if (container[j] < gemiddelde)
  58.                 {
  59.                     kk++;
  60.  
  61.                
  62.                 }
  63.  
  64.                  
  65.             }
  66.             klein = new int[kk];
  67.             groot = new int[container.Length - kk];
  68.            
  69.  
  70.  
  71.         }
  72.  
  73.  
  74.     }
  75. }
  76.  
  77.  
  78.  
  79.  
  80. using System;
  81. using System.Collections.Generic;
  82. using System.ComponentModel;
  83. using System.Data;
  84. using System.Drawing;
  85. using System.Linq;
  86. using System.Text;
  87. using System.Windows.Forms;
  88.  
  89. namespace quicksort_test
  90. {
  91.     public partial class Form1 : Form
  92.     {
  93.         public Form1()
  94.         {
  95.             InitializeComponent();
  96.         }
  97.  
  98.         int r = 20;
  99.         int[] container = new int[20];
  100.  
  101.         private void button1_Click(object sender, EventArgs e)
  102.         {
  103.             listBox1.Items.Clear();
  104.             for (int i = 0; i < r; i++)
  105.             {
  106.                 listBox1.Items.Add(Modnar.willekeurig()); //Add random to listbox
  107.                 container[i] = Convert.ToInt32(listBox1.Items[i]);//Imidiatly put them in array
  108.             }
  109.         }
  110.         private void button2_Click(object sender, EventArgs e)
  111.         {
  112.             int[] klein; // the items in array container will be divided in two arrays,
  113.             int[] groot;        
  114.             int kk = 0;
  115.             int gemiddelde = container.Sum() / container.Length;
  116.             for (int j = 0; j < container.Length; j++)
  117.             {
  118.                 if (container[j] < gemiddelde)
  119.                 {
  120.                     kk++;
  121.                 }  
  122.             } // and in those arrays they will be divided again in two arrays
  123.             klein = new int[kk];
  124.             groot = new int[container.Length - kk];
  125.         }
  126.     }
  127. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement