Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Runtime.InteropServices.WindowsRuntime;
- using Windows.Foundation;
- using Windows.Foundation.Collections;
- using Windows.UI.Xaml;
- using Windows.UI.Xaml.Controls;
- using Windows.UI.Xaml.Controls.Primitives;
- using Windows.UI.Xaml.Data;
- using Windows.UI.Xaml.Input;
- using Windows.UI.Xaml.Media;
- using Windows.UI.Xaml.Navigation;
- // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
- namespace Bubblesort
- {
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public sealed partial class MainPage : Page
- {
- int[] arr = new int[10]; //Legt einen int-Array mit der Länge 10 an.
- String outputstring = "";
- Random randNum = new Random();
- public MainPage()
- {
- this.InitializeComponent();
- //Array wird mit ganzen Zahlen gefüllt
- for (int i = 0; i < arr.Length; i++)
- {
- arr[i] = randNum.Next(1, 100);
- }
- //Umwandeln des Arrays in einen String zur Ausgabe in einem Textfeld
- String inputstring = "";
- for (int i = 0; i < arr.Length; i++)
- {
- inputstring += arr[i] + " | ";
- }
- tbx_input.Text = inputstring;
- }
- public int[] sort(int[] a)
- {
- bool flag = true;
- int temp;
- int numLength = a.Length;
- //sorting an array
- for (int i = 1; (i <= (numLength - 1)) && flag; i++)
- {
- flag = false;
- for (int j = 0; j < (numLength - 1); j++)
- {
- if (a[j + 1] < a[j])
- {
- temp = a[j];
- a[j] = a[j + 1];
- a[j + 1] = temp;
- flag = true;
- }
- for (int z = 0; z < a.Length; z++)
- {
- outputstring += a[z] + " | ";
- }
- outputstring += "\r\n";
- }
- }
- tbx_output.Text = outputstring;
- return a;
- }
- private void b_bubblesort_Click(object sender, RoutedEventArgs e)
- {
- int[] z = sort(arr);
- }
- private void b_quicksort_Click(object sender, RoutedEventArgs e)
- {
- int[] z = sort(arr);
- }
- private void b_insertionsort_Click(object sender, RoutedEventArgs e)
- {
- int[] z = sort(arr);
- }
- private void b_mergesort_Click(object sender, RoutedEventArgs e)
- {
- int[] z = sort(arr);
- }
- }
- }
- +++++++++++++++++++++++++++++
- <Page
- x:Class="Bubblesort.MainPage"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:local="using:Bubblesort"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- mc:Ignorable="d" FontFamily="Century Gothic" Foreground="{x:Null}">
- <Grid Background="Black">
- <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"/>
- <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"/>
- <TextBox x:Name="tbx_input" Margin="384,0,505,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" FontSize="16" FontFamily="Century Gothic" Foreground="White" Height="128"/>
- <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"/>
- <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"/>
- <Grid HorizontalAlignment="Left" Height="98" Margin="0,622,0,0" VerticalAlignment="Top" Width="385">
- <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"/>
- <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"/>
- <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"/>
- <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"/>
- </Grid>
- </Grid>
- </Page>
Advertisement
Advertisement
Advertisement
RAW Paste Data
Copied
Advertisement