eksemum 3 年之前
父节点
当前提交
20b95c9b58
共有 7 个文件被更改,包括 234 次插入0 次删除
  1. 25 0
      SORTER.sln
  2. 9 0
      SORTER/App.xaml
  3. 17 0
      SORTER/App.xaml.cs
  4. 10 0
      SORTER/AssemblyInfo.cs
  5. 10 0
      SORTER/MainWindow.xaml
  6. 154 0
      SORTER/MainWindow.xaml.cs
  7. 9 0
      SORTER/SORTER.csproj

+ 25 - 0
SORTER.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31605.320
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SORTER", "SORTER\SORTER.csproj", "{2734C2E0-DAEA-4312-A462-7A4F20593CA9}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{2734C2E0-DAEA-4312-A462-7A4F20593CA9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{2734C2E0-DAEA-4312-A462-7A4F20593CA9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{2734C2E0-DAEA-4312-A462-7A4F20593CA9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{2734C2E0-DAEA-4312-A462-7A4F20593CA9}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {20ACCB87-1761-4DA9-98E1-1186CA213847}
+	EndGlobalSection
+EndGlobal

+ 9 - 0
SORTER/App.xaml

@@ -0,0 +1,9 @@
+<Application x:Class="SORTER.App"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:local="clr-namespace:SORTER"
+             StartupUri="MainWindow.xaml">
+    <Application.Resources>
+         
+    </Application.Resources>
+</Application>

+ 17 - 0
SORTER/App.xaml.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace SORTER
+{
+    /// <summary>
+    /// Interaction logic for App.xaml
+    /// </summary>
+    public partial class App : Application
+    {
+    }
+}

+ 10 - 0
SORTER/AssemblyInfo.cs

@@ -0,0 +1,10 @@
+using System.Windows;
+
+[assembly: ThemeInfo(
+    ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
+                                     //(used if a resource is not found in the page,
+                                     // or application resource dictionaries)
+    ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
+                                              //(used if a resource is not found in the page,
+                                              // app, or any theme specific resource dictionaries)
+)]

+ 10 - 0
SORTER/MainWindow.xaml

@@ -0,0 +1,10 @@
+<Window x:Class="SORTER.MainWindow"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:SORTER"
+        mc:Ignorable="d"
+        Title="Sorter" Height="450" Width="800">
+    <Grid/>
+</Window>

+ 154 - 0
SORTER/MainWindow.xaml.cs

@@ -0,0 +1,154 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace SORTER
+{
+    /// <summary>
+    /// Interaction logic for MainWindow.xaml
+    /// </summary>
+    public partial class MainWindow : Window
+    {
+        int[] array = new int[100] { 1, 5, 4, 3, 2, 6, 8, 7, 10, 9, 11, 15, 13, 12, 14, 18, 16, 17, 19, 23, 21, 20, 22, 30, 43, 53, 23, 26, 78, 28, 15, 90, 99, 22, 76, 55, 68, 23, 54, 43, 46, 41, 51, 59, 91, 5, 3, 16, 17, 29, 34, 36, 76, 88, 84, 43, 95, 93, 23, 67, 64, 34, 38, 32, 23, 26, 84, 89, 94, 97, 12, 3, 5, 8, 9, 54, 67, 76, 72, 12, 16, 17, 18, 20, 33, 1, 32, 86, 98, 32, 24, 27, 19, 87, 98, 43, 29, 98, 78, 82};
+
+        public MainWindow()
+        {
+            InitializeComponent();
+            //linearSelectionSort();
+            //methodMinMax();
+            //BubbleSort();
+            ShuttleSort();
+        }
+
+
+        void linearSelectionSort()
+        {
+            List<int> arraySorted = new List<int>();
+            int max = int.MinValue;
+            int index = 0;
+
+            while (arraySorted.Count < 100)
+            {
+                for (int i = 0; i < array.Length; ++i)
+                {
+                    if (max <= array[i] && array[i] != 100)
+                    {
+                        max = array[i];
+                        index = i;
+                    }
+                }
+                array[index] = 100;
+                arraySorted.Add(max);
+                max = int.MinValue;
+            }
+
+            string foo = "";
+
+            for (int i = 0; i < arraySorted.Count; ++i)
+            {
+                foo += arraySorted[i].ToString() + " ";
+            }
+
+            MessageBox.Show(foo);
+        }
+
+
+        void methodMinMax()
+        {
+
+            for (int i = 0; i < array.Length - 1; ++i)
+            {
+                int max = i;
+
+                for (int j = i + 1; j < array.Length; ++j)
+                {
+                    if (array[j].CompareTo(array[max]) > 0)
+                    {
+                        max = j;
+                    }
+                }
+
+                int temp = array[i];
+                array[i] = array[max];
+                array[max] = temp;
+            }
+
+
+            string foo = "";
+
+            for (int i = 0; i < array.Length; ++i)
+            {
+                foo += array[i] + " ";
+            }
+
+            MessageBox.Show(foo);
+        }
+
+
+        void BubbleSort()
+        {
+
+            int temp = 0;
+            for (int i = 0; i < array.Length - 1; i++)
+            {
+                for (int j = 0; j < array.Length - i - 1; j++)
+                {
+                    if (array[j + 1] < array[j])
+                    {
+                        temp = array[j + 1];
+                        array[j + 1] = array[j];
+                        array[j] = temp;
+                    }
+                }
+            }
+
+            string foo = "";
+
+            for (int i = 0; i < array.Length; ++i)
+            {
+                foo += array[i] + " ";
+            }
+
+            MessageBox.Show(foo);
+        }
+
+
+        void ShuttleSort()
+        {
+
+            int temp = 0;
+            for (int i = 0; i < array.Length - 1; i++)
+            {
+                for (int j = 0; j < array.Length - i - 1; j++)
+                {
+                    if (array[j + 1] < array[j])
+                    {
+                        temp = array[j + 1];
+                        array[j + 1] = array[j];
+                        array[j] = temp;
+                    }
+                }
+            }
+
+            string foo = "";
+
+            for (int i = 0; i < array.Length; ++i)
+            {
+                foo += array[i] + " ";
+            }
+
+            MessageBox.Show(foo);
+        }
+    }
+}

+ 9 - 0
SORTER/SORTER.csproj

@@ -0,0 +1,9 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>WinExe</OutputType>
+    <TargetFramework>net5.0-windows</TargetFramework>
+    <UseWPF>true</UseWPF>
+  </PropertyGroup>
+
+</Project>