mathiaspl20

Untitled

Feb 10th, 2017
158
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.IO;
  4. using System.Linq;
  5. using System.Runtime.InteropServices.WindowsRuntime;
  6. using Windows.Foundation;
  7. using Windows.Foundation.Collections;
  8. using Windows.UI.Xaml;
  9. using Windows.UI.Xaml.Controls;
  10. using Windows.UI.Xaml.Controls.Primitives;
  11. using Windows.UI.Xaml.Data;
  12. using Windows.UI.Xaml.Input;
  13. using Windows.UI.Xaml.Media;
  14. using Windows.UI.Xaml.Navigation;
  15.  
  16. // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
  17.  
  18. namespace Bubblesort
  19. {
  20. /// <summary>
  21. /// An empty page that can be used on its own or navigated to within a Frame.
  22. /// </summary>
  23. public sealed partial class MainPage : Page
  24. {
  25. int[] arr = new int[10]; //Legt einen int-Array mit der Länge 10 an.
  26. String outputstring = "";
  27.  
  28. Random randNum = new Random();
  29.  
  30.  
  31. public MainPage()
  32. {
  33. this.InitializeComponent();
  34. //Array wird mit ganzen Zahlen gefüllt
  35. for (int i = 0; i < arr.Length; i++)
  36. {
  37. arr[i] = randNum.Next(1, 100);
  38. }
  39.  
  40. //Umwandeln des Arrays in einen String zur Ausgabe in einem Textfeld
  41. String inputstring = "";
  42.  
  43. for (int i = 0; i < arr.Length; i++)
  44. {
  45. inputstring += arr[i] + " | ";
  46. }
  47.  
  48. tbx_input.Text = inputstring;
  49.  
  50. }
  51.  
  52. public int[] sort(int[] a)
  53. {
  54. bool flag = true;
  55. int temp;
  56. int numLength = a.Length;
  57. //sorting an array
  58.  
  59. for (int i = 1; (i <= (numLength - 1)) && flag; i++)
  60. {
  61. flag = false;
  62. for (int j = 0; j < (numLength - 1); j++)
  63. {
  64. if (a[j + 1] < a[j])
  65. {
  66. temp = a[j];
  67. a[j] = a[j + 1];
  68. a[j + 1] = temp;
  69. flag = true;
  70. }
  71.  
  72. for (int z = 0; z < a.Length; z++)
  73. {
  74. outputstring += a[z] + " | ";
  75.  
  76. }
  77. outputstring += "\r\n";
  78. }
  79.  
  80.  
  81.  
  82.  
  83. }
  84. tbx_output.Text = outputstring;
  85. return a;
  86.  
  87. }
  88.  
  89. private void b_bubblesort_Click(object sender, RoutedEventArgs e)
  90. {
  91.  
  92. int[] z = sort(arr);
  93.  
  94.  
  95.  
  96.  
  97. }
  98. private void b_quicksort_Click(object sender, RoutedEventArgs e)
  99. {
  100.  
  101. int[] z = sort(arr);
  102.  
  103.  
  104.  
  105.  
  106. }
  107. private void b_insertionsort_Click(object sender, RoutedEventArgs e)
  108. {
  109.  
  110. int[] z = sort(arr);
  111.  
  112.  
  113.  
  114.  
  115. }
  116. private void b_mergesort_Click(object sender, RoutedEventArgs e)
  117. {
  118.  
  119. int[] z = sort(arr);
  120.  
  121.  
  122.  
  123.  
  124. }
  125. }
  126. }
  127. +++++++++++++++++++++++++++++
  128. <Page
  129. x:Class="Bubblesort.MainPage"
  130. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  131. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  132. xmlns:local="using:Bubblesort"
  133. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  134. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  135. mc:Ignorable="d" FontFamily="Century Gothic" Foreground="{x:Null}">
  136.  
  137. <Grid Background="Black">
  138. <TextBlock x:Name="tbl_head" TextWrapping="Wrap" FontSize="100" Text="Sort" FontFamily="Century Gothic" FontWeight="Bold" VerticalAlignment="Top" Foreground="White" Height="98" Margin="0,0,1096,0"/>
  139. <TextBlock x:Name="tbl_input" TextWrapping="Wrap" Text="INPUT" FontSize="18" FontFamily="Century Gothic" VerticalAlignment="Center" Margin="389,2,843,692" Foreground="White" Height="26"/>
  140. <TextBox x:Name="tbx_input" Margin="384,0,505,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" FontSize="16" FontFamily="Century Gothic" Foreground="White" Height="128"/>
  141. <TextBlock x:Name="tbl_output" TextWrapping="Wrap" Text="OUTPUT" FontSize="16" FontFamily="Century Gothic" VerticalAlignment="Center" Margin="780,4,427,694" Foreground="White" Height="22"/>
  142. <TextBox x:Name="tbx_output" TextWrapping="Wrap" Text="" FontSize="16" FontFamily="Century Gothic" Foreground="White" Height="720" HorizontalAlignment="Right" Width="500" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"/>
  143. <Grid HorizontalAlignment="Left" Height="98" Margin="0,622,0,0" VerticalAlignment="Top" Width="385">
  144. <Button x:Name="b_bubblesort" Content="Bubblesort" HorizontalAlignment="Left" Margin="0,49,0,0" VerticalAlignment="Top" Height="49" Width="200" Click="b_bubblesort_Click" FontFamily="Century Gothic" FontSize="30" Foreground="White"/>
  145. <Button x:Name="b_mergesort" Content="Mergesort" HorizontalAlignment="Left" Margin="185,49,0,0" VerticalAlignment="Top" Height="49" Width="200" Click="b_bubblesort_Click" FontFamily="Century Gothic" FontSize="30" Foreground="White"/>
  146. <Button x:Name="b_insertionsort" Content="Insertionsort" HorizontalAlignment="Left" VerticalAlignment="Top" Height="49" Width="200" Click="b_bubblesort_Click" FontFamily="Century Gothic" FontSize="30" Foreground="White"/>
  147. <Button x:Name="b_quicksort" Content="Quicksort" HorizontalAlignment="Left" Margin="205,0,0,0" VerticalAlignment="Top" Height="49" Width="180" Click="b_bubblesort_Click" FontFamily="Century Gothic" FontSize="30" Foreground="White"/>
  148. </Grid>
  149.  
  150. </Grid>
  151. </Page>
RAW Paste Data