upload
This commit is contained in:
63
.gitattributes
vendored
Normal file
63
.gitattributes
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
||||
363
.gitignore
vendored
Normal file
363
.gitignore
vendored
Normal file
@@ -0,0 +1,363 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Oo]ut/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
85
AnalysisWindow.xaml
Normal file
85
AnalysisWindow.xaml
Normal file
@@ -0,0 +1,85 @@
|
||||
<Window x:Class="Lab9.AnalysisWindow"
|
||||
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"
|
||||
mc:Ignorable="d"
|
||||
Title="Анализ производительности"
|
||||
Height="620"
|
||||
Width="1080"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Background="#FFF4F6F8">
|
||||
<Grid Margin="14">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="12"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="12"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="12"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<DockPanel Grid.Row="0">
|
||||
<Button Content="Назад"
|
||||
Width="110"
|
||||
Background="#FF5D6D7E"
|
||||
Foreground="White"
|
||||
Click="Close_Click"/>
|
||||
<TextBlock Margin="14,6,0,0"
|
||||
VerticalAlignment="Center"
|
||||
FontWeight="Bold"
|
||||
FontSize="20"
|
||||
Text="Сравнительный анализ эффективности"/>
|
||||
</DockPanel>
|
||||
|
||||
<DataGrid x:Name="AnalysisDataGrid"
|
||||
Grid.Row="2"
|
||||
AutoGenerateColumns="False"
|
||||
IsReadOnly="True"
|
||||
HeadersVisibility="Column"
|
||||
CanUserAddRows="False"
|
||||
CanUserDeleteRows="False"
|
||||
Margin="0"
|
||||
RowHeight="44">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Количество элементов"
|
||||
Binding="{Binding ElementCount}"
|
||||
Width="160"/>
|
||||
<DataGridTextColumn Header="TimSort"
|
||||
Binding="{Binding TimSort}"
|
||||
Width="*"/>
|
||||
<DataGridTextColumn Header="MSD"
|
||||
Binding="{Binding Msd}"
|
||||
Width="*"/>
|
||||
<DataGridTextColumn Header="Коммунистическая сортировка"
|
||||
Binding="{Binding Communist}"
|
||||
Width="*"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<Border Grid.Row="4"
|
||||
Background="White"
|
||||
BorderBrush="#FFD6DCE2"
|
||||
BorderThickness="1"
|
||||
CornerRadius="8"
|
||||
Padding="12">
|
||||
<StackPanel>
|
||||
<TextBlock FontWeight="Bold"
|
||||
FontSize="16"
|
||||
Margin="0,0,0,8"
|
||||
Text="Анализ"/>
|
||||
<TextBlock x:Name="AnalysisSummaryTextBlock"
|
||||
TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Button Grid.Row="6"
|
||||
Content="Начать анализ заново"
|
||||
HorizontalAlignment="Right"
|
||||
Width="180"
|
||||
Background="#FF1E9C58"
|
||||
Foreground="White"
|
||||
Click="Recalculate_Click"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
105
AnalysisWindow.xaml.cs
Normal file
105
AnalysisWindow.xaml.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using Lab9.Models;
|
||||
using Lab9.Services;
|
||||
using Lab9.Strategies;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace Lab9;
|
||||
|
||||
public partial class AnalysisWindow : Window
|
||||
{
|
||||
private readonly IReadOnlyList<ISortStrategy> _strategies;
|
||||
private readonly bool _descending;
|
||||
private readonly ObservableCollection<AnalysisRow> _rows = new();
|
||||
|
||||
public AnalysisWindow(IReadOnlyList<ISortStrategy> strategies, bool descending)
|
||||
{
|
||||
InitializeComponent();
|
||||
_strategies = strategies;
|
||||
_descending = descending;
|
||||
|
||||
AnalysisDataGrid.ItemsSource = _rows;
|
||||
Recalculate();
|
||||
}
|
||||
|
||||
private void Recalculate_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Recalculate();
|
||||
}
|
||||
|
||||
private void Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Recalculate()
|
||||
{
|
||||
_rows.Clear();
|
||||
|
||||
var sizes = new[] { 10, 100, 150 };
|
||||
var random = new Random(4233);
|
||||
var collected = new Dictionary<string, List<SortResult>>();
|
||||
|
||||
foreach (var strategy in _strategies)
|
||||
{
|
||||
collected[strategy.Name] = new List<SortResult>();
|
||||
}
|
||||
|
||||
foreach (var size in sizes)
|
||||
{
|
||||
var baseArray = Enumerable.Range(0, size)
|
||||
.Select(_ => random.Next(-250, 1000))
|
||||
.ToArray();
|
||||
|
||||
var row = new AnalysisRow { ElementCount = size };
|
||||
|
||||
foreach (var strategy in _strategies)
|
||||
{
|
||||
var context = new SortingContext(strategy);
|
||||
var result = context.Execute(baseArray, ascending: !_descending, enableLogging: false);
|
||||
collected[strategy.Name].Add(result);
|
||||
|
||||
var cellText = $"C: {result.Metrics.Comparisons} | П: {result.Metrics.Moves} | В: {result.Elapsed.TotalMilliseconds:F6} мс";
|
||||
switch (strategy)
|
||||
{
|
||||
case TimSortStrategy:
|
||||
row.TimSort = cellText;
|
||||
break;
|
||||
case MsdRadixSortStrategy:
|
||||
row.Msd = cellText;
|
||||
break;
|
||||
case CommunistSortStrategy:
|
||||
row.Communist = cellText;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_rows.Add(row);
|
||||
}
|
||||
|
||||
AnalysisSummaryTextBlock.Text = BuildSummary(collected);
|
||||
}
|
||||
|
||||
private string BuildSummary(Dictionary<string, List<SortResult>> collected)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
|
||||
var timSortAverage = collected["TimSort"].Average(x => x.Elapsed.TotalMilliseconds);
|
||||
var msdAverage = collected["MSD Radix Sort"].Average(x => x.Elapsed.TotalMilliseconds);
|
||||
var communistAverage = collected["Коммунистическая сортировка"].Average(x => x.Elapsed.TotalMilliseconds);
|
||||
|
||||
builder.AppendLine(
|
||||
timSortAverage <= msdAverage
|
||||
? "• TimSort в среднем показал меньшее время на тестовых массивах."
|
||||
: "• MSD в среднем показал меньшее время на тестовых массивах.");
|
||||
|
||||
builder.AppendLine("• MSD - алгоритм без прямого сравнения ключей, поэтому число сравнений у него заметно меньше либо равно нулю.");
|
||||
builder.AppendLine("• TimSort удобен как гибрид: на малых участках он опирается на вставки, а затем выполняет слияние.");
|
||||
builder.AppendLine("• Коммунистическая сортировка использует собственный принцип обработки массива и участвует в общем сравнительном анализе.");
|
||||
builder.AppendLine(
|
||||
$"• Среднее время: TimSort = {timSortAverage:F6} мс, MSD = {msdAverage:F6} мс, Коммунистическая = {communistAverage:F6} мс.");
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
9
App.xaml
Normal file
9
App.xaml
Normal file
@@ -0,0 +1,9 @@
|
||||
<Application x:Class="Lab9.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Lab9"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
14
App.xaml.cs
Normal file
14
App.xaml.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Windows;
|
||||
|
||||
namespace Lab9
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
10
AssemblyInfo.cs
Normal file
10
AssemblyInfo.cs
Normal file
@@ -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)
|
||||
)]
|
||||
11
Lab9.csproj
Normal file
11
Lab9.csproj
Normal file
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net9.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
25
Lab9.sln
Normal file
25
Lab9.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.36429.23 d17.14
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lab9", "Lab9.csproj", "{6A79F10C-033D-4C05-B89F-384659B34F80}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6A79F10C-033D-4C05-B89F-384659B34F80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6A79F10C-033D-4C05-B89F-384659B34F80}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6A79F10C-033D-4C05-B89F-384659B34F80}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6A79F10C-033D-4C05-B89F-384659B34F80}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {DEA5977A-25DC-4E37-A800-413AD72574E7}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
205
MainWindow.xaml
Normal file
205
MainWindow.xaml
Normal file
@@ -0,0 +1,205 @@
|
||||
<Window x:Class="Lab9.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:Lab9"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow"
|
||||
Height="760"
|
||||
Width="1280"
|
||||
MinHeight="720"
|
||||
MinWidth="1180"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Background="#FFF4F6F8">
|
||||
<Grid Margin="14">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="370"/>
|
||||
<ColumnDefinition Width="14"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border Grid.Column="0"
|
||||
Background="White"
|
||||
CornerRadius="10"
|
||||
Padding="14"
|
||||
BorderBrush="#FFD6DCE2"
|
||||
BorderThickness="1">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto">
|
||||
<StackPanel>
|
||||
<TextBlock FontSize="22"
|
||||
FontWeight="Bold"
|
||||
Margin="0,0,0,6"
|
||||
Text="Сортировка массивов"/>
|
||||
<TextBlock Foreground="#FF5C6B7A"
|
||||
Margin="0,0,0,16"
|
||||
TextWrapping="Wrap">
|
||||
Вариант: TimSort, MSD, Коммунистическая сортировка.
|
||||
Выполнено по паттерну «Стратегия», плюс переключение направления сортировки.
|
||||
</TextBlock>
|
||||
|
||||
<GroupBox Header="Генерация массива">
|
||||
<StackPanel>
|
||||
<TextBlock Margin="0,0,0,6" Text="Количество элементов массива"/>
|
||||
<Slider x:Name="ElementCountSlider"
|
||||
Minimum="5"
|
||||
Maximum="150"
|
||||
TickFrequency="5"
|
||||
IsSnapToTickEnabled="True"
|
||||
Value="20"
|
||||
ValueChanged="ElementCountSlider_ValueChanged"/>
|
||||
<DockPanel Margin="0,10,0,0">
|
||||
<TextBlock VerticalAlignment="Center" Text="Текущее значение:"/>
|
||||
<TextBox x:Name="ElementCountTextBox"
|
||||
Width="70"
|
||||
Margin="10,0,0,0"
|
||||
Text="20"
|
||||
HorizontalContentAlignment="Center"
|
||||
TextChanged="ElementCountTextBox_TextChanged"/>
|
||||
</DockPanel>
|
||||
|
||||
<Button Content="Сгенерировать массив"
|
||||
Background="#FF2793FF"
|
||||
Foreground="White"
|
||||
Click="GenerateArray_Click"/>
|
||||
<Button Content="Массив из файла"
|
||||
Background="#FF7F8C9A"
|
||||
Foreground="White"
|
||||
Click="LoadFromFile_Click"/>
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Header="Методы сортировки">
|
||||
<StackPanel>
|
||||
<RadioButton x:Name="TimSortRadioButton"
|
||||
Content="TimSort"
|
||||
IsChecked="True"
|
||||
Margin="0,0,0,6"/>
|
||||
<RadioButton x:Name="MsdRadioButton"
|
||||
Content="MSD Radix Sort"
|
||||
Margin="0,0,0,6"/>
|
||||
<RadioButton x:Name="CommunistRadioButton"
|
||||
Content="Коммунистическая сортировка"
|
||||
Margin="0,0,0,8"/>
|
||||
<CheckBox x:Name="DescendingCheckBox"
|
||||
Content="Сортировать по убыванию"
|
||||
ToolTip="Если флажок снят, сортировка выполняется по возрастанию."/>
|
||||
</StackPanel>
|
||||
</GroupBox>
|
||||
|
||||
<GroupBox Header="Результат сортировки">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="185"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="Количество сравнений:"/>
|
||||
<TextBlock Grid.Row="0" Grid.Column="1" x:Name="ComparisonsTextBlock" Text="0"/>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Margin="0,6,0,0" Text="Количество пересылок:"/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1" Margin="0,6,0,0" x:Name="MovesTextBlock" Text="0"/>
|
||||
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Margin="0,6,0,0" Text="Время сортировки:"/>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1" Margin="0,6,0,0" x:Name="ElapsedTextBlock" Text="00:00:00.000"/>
|
||||
|
||||
<TextBlock Grid.Row="3"
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="0,10,0,0"
|
||||
Foreground="#FF8A5A00"
|
||||
TextWrapping="Wrap"
|
||||
Text="Для MSD число сравнений может быть нулевым, потому что алгоритм не основан на сравнении ключей."/>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
<Button Content="Начать сортировку"
|
||||
Background="#FF1E9C58"
|
||||
Foreground="White"
|
||||
Click="StartSorting_Click"/>
|
||||
|
||||
<Button Content="Очистить значения"
|
||||
Background="#FFE74C3C"
|
||||
Foreground="White"
|
||||
Click="Clear_Click"/>
|
||||
|
||||
<Button Content="Сохранить в файл"
|
||||
Background="#FF1F3BFF"
|
||||
Foreground="White"
|
||||
Click="SaveToFile_Click"/>
|
||||
|
||||
<Button Content="Анализ методов сортировки"
|
||||
Background="#FFF39C12"
|
||||
Foreground="Black"
|
||||
Click="OpenAnalysis_Click"/>
|
||||
|
||||
<Border Background="#FFF8F9FB"
|
||||
BorderBrush="#FFD6DCE2"
|
||||
BorderThickness="1"
|
||||
CornerRadius="8"
|
||||
Padding="10"
|
||||
Margin="0,10,0,0">
|
||||
<TextBlock TextWrapping="Wrap"
|
||||
Foreground="#FF45525F">
|
||||
Коммунистическая сортировка реализована как отдельный метод обработки массива
|
||||
с приведением элементов к общему значению.
|
||||
</TextBlock>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Column="2"
|
||||
Background="White"
|
||||
CornerRadius="10"
|
||||
Padding="14"
|
||||
BorderBrush="#FFD6DCE2"
|
||||
BorderThickness="1">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="14"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock FontSize="20"
|
||||
FontWeight="Bold"
|
||||
Text="Пошаговая демонстрация работы алгоритма"/>
|
||||
|
||||
<Border Grid.Row="1"
|
||||
Margin="0,12,0,0"
|
||||
Background="#FFF8F9FB"
|
||||
BorderBrush="#FFD6DCE2"
|
||||
BorderThickness="1"
|
||||
CornerRadius="8"
|
||||
Padding="10">
|
||||
<StackPanel>
|
||||
<TextBlock FontWeight="SemiBold" Text="Исходный / текущий массив"/>
|
||||
<TextBlock x:Name="ArrayPreviewTextBlock"
|
||||
Margin="0,6,0,0"
|
||||
FontFamily="Consolas"
|
||||
TextWrapping="Wrap"
|
||||
Text="Массив ещё не сформирован."/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<RichTextBox x:Name="LogRichTextBox"
|
||||
Grid.Row="3"
|
||||
FontFamily="Consolas"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
IsReadOnly="True"
|
||||
IsDocumentEnabled="False"
|
||||
Background="#FFFCFCFD"
|
||||
BorderThickness="0"
|
||||
Padding="8"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
||||
311
MainWindow.xaml.cs
Normal file
311
MainWindow.xaml.cs
Normal file
@@ -0,0 +1,311 @@
|
||||
using Microsoft.Win32;
|
||||
using Lab9.Models;
|
||||
using Lab9.Services;
|
||||
using Lab9.Strategies;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Lab9
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private readonly SortingContext _context = new();
|
||||
private readonly IReadOnlyList<ISortStrategy> _strategies;
|
||||
private int[] _currentArray = Array.Empty<int>();
|
||||
private SortResult? _lastResult;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_strategies = new List<ISortStrategy>
|
||||
{
|
||||
new TimSortStrategy(),
|
||||
new MsdRadixSortStrategy(),
|
||||
new CommunistSortStrategy()
|
||||
};
|
||||
|
||||
UpdatePreview("Массив ещё не сформирован.");
|
||||
ResetMetrics();
|
||||
}
|
||||
|
||||
private void ElementCountSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
||||
{
|
||||
if (!IsLoaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ElementCountTextBox.Text = ((int)ElementCountSlider.Value).ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
private void ElementCountTextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
|
||||
{
|
||||
if (!IsLoaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (int.TryParse(ElementCountTextBox.Text, out var value))
|
||||
{
|
||||
value = Math.Clamp(value, (int)ElementCountSlider.Minimum, (int)ElementCountSlider.Maximum);
|
||||
ElementCountSlider.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateArray_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var count = (int)ElementCountSlider.Value;
|
||||
var random = new Random();
|
||||
_currentArray = Enumerable.Range(0, count)
|
||||
.Select(_ => random.Next(-250, 1000))
|
||||
.ToArray();
|
||||
|
||||
_lastResult = null;
|
||||
ClearLog();
|
||||
ResetMetrics();
|
||||
UpdatePreview($"Исходный массив:{Environment.NewLine}{FormatArray(_currentArray)}");
|
||||
}
|
||||
|
||||
private void LoadFromFile_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new OpenFileDialog
|
||||
{
|
||||
Filter = "Текстовые файлы (*.txt)|*.txt|Все файлы (*.*)|*.*"
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() != true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_currentArray = ArrayIoService.ReadArrayFromFile(dialog.FileName);
|
||||
_lastResult = null;
|
||||
ClearLog();
|
||||
ResetMetrics();
|
||||
UpdatePreview($"Массив из файла:{Environment.NewLine}{FormatArray(_currentArray)}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(
|
||||
$"Не удалось прочитать файл.\n{ex.Message}",
|
||||
"Ошибка",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void StartSorting_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_currentArray.Length == 0)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Сначала сгенерируй массив или загрузи его из файла. Машина без данных сортирует только воздух.",
|
||||
"Ошибка",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var strategy = GetSelectedStrategy();
|
||||
var ascending = DescendingCheckBox.IsChecked != true;
|
||||
|
||||
_context.ContextStrategy = strategy;
|
||||
_lastResult = _context.Execute(_currentArray, ascending, enableLogging: true);
|
||||
|
||||
ComparisonsTextBlock.Text = _lastResult.Metrics.Comparisons.ToString(CultureInfo.InvariantCulture);
|
||||
MovesTextBlock.Text = _lastResult.Metrics.Moves.ToString(CultureInfo.InvariantCulture);
|
||||
ElapsedTextBlock.Text = $"{_lastResult.Elapsed.TotalMilliseconds:F6} мс";
|
||||
|
||||
RenderLog(_lastResult.Log);
|
||||
UpdatePreview(
|
||||
$"Исходный массив:{Environment.NewLine}{FormatArray(_currentArray)}{Environment.NewLine}{Environment.NewLine}" +
|
||||
$"Результат ({_lastResult.AlgorithmName}):{Environment.NewLine}{FormatArray(_lastResult.SortedArray)}");
|
||||
}
|
||||
|
||||
private void SaveToFile_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_currentArray.Length == 0)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"Сохранять пока нечего. Даже файл не любит пустые жесты.",
|
||||
"Ошибка",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "Текстовые файлы (*.txt)|*.txt",
|
||||
FileName = "sorting_result.txt"
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() != true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var content = BuildExportContent();
|
||||
File.WriteAllText(dialog.FileName, content, Encoding.UTF8);
|
||||
|
||||
MessageBox.Show(
|
||||
"Результаты сохранены в файл.",
|
||||
"Готово",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(
|
||||
$"Не удалось сохранить файл.\n{ex.Message}",
|
||||
"Ошибка",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void Clear_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_currentArray = Array.Empty<int>();
|
||||
_lastResult = null;
|
||||
ClearLog();
|
||||
ResetMetrics();
|
||||
UpdatePreview("Массив очищен.");
|
||||
}
|
||||
|
||||
private void OpenAnalysis_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var analysisWindow = new AnalysisWindow(_strategies, DescendingCheckBox.IsChecked == true)
|
||||
{
|
||||
Owner = this
|
||||
};
|
||||
|
||||
analysisWindow.ShowDialog();
|
||||
}
|
||||
|
||||
private ISortStrategy GetSelectedStrategy()
|
||||
{
|
||||
if (MsdRadioButton.IsChecked == true)
|
||||
{
|
||||
return _strategies.OfType<MsdRadixSortStrategy>().First();
|
||||
}
|
||||
|
||||
if (CommunistRadioButton.IsChecked == true)
|
||||
{
|
||||
return _strategies.OfType<CommunistSortStrategy>().First();
|
||||
}
|
||||
|
||||
return _strategies.OfType<TimSortStrategy>().First();
|
||||
}
|
||||
|
||||
private void ResetMetrics()
|
||||
{
|
||||
ComparisonsTextBlock.Text = "0";
|
||||
MovesTextBlock.Text = "0";
|
||||
ElapsedTextBlock.Text = "0.000000 мс";
|
||||
}
|
||||
|
||||
private void UpdatePreview(string text)
|
||||
{
|
||||
ArrayPreviewTextBlock.Text = text;
|
||||
}
|
||||
|
||||
private void ClearLog()
|
||||
{
|
||||
LogRichTextBox.Document.Blocks.Clear();
|
||||
}
|
||||
|
||||
private static string FormatArray(int[] array)
|
||||
{
|
||||
if (array.Length == 0)
|
||||
{
|
||||
return "Пустой массив.";
|
||||
}
|
||||
|
||||
return string.Join(" ", array);
|
||||
}
|
||||
|
||||
private void RenderLog(string log)
|
||||
{
|
||||
LogRichTextBox.Document.Blocks.Clear();
|
||||
|
||||
var regex = new Regex(@"\[-?\d+\]", RegexOptions.Compiled);
|
||||
var lines = log.Replace("\r\n", "\n").Split('\n');
|
||||
|
||||
foreach (var line in lines)
|
||||
{
|
||||
var paragraph = new Paragraph
|
||||
{
|
||||
Margin = new Thickness(0)
|
||||
};
|
||||
|
||||
if (string.IsNullOrWhiteSpace(line))
|
||||
{
|
||||
paragraph.Inlines.Add(new Run(" "));
|
||||
LogRichTextBox.Document.Blocks.Add(paragraph);
|
||||
continue;
|
||||
}
|
||||
|
||||
var lastIndex = 0;
|
||||
|
||||
foreach (Match match in regex.Matches(line))
|
||||
{
|
||||
if (match.Index > lastIndex)
|
||||
{
|
||||
paragraph.Inlines.Add(new Run(line.Substring(lastIndex, match.Index - lastIndex)));
|
||||
}
|
||||
|
||||
paragraph.Inlines.Add(new Run(match.Value)
|
||||
{
|
||||
Background = Brushes.LightSkyBlue,
|
||||
FontWeight = FontWeights.Bold
|
||||
});
|
||||
|
||||
lastIndex = match.Index + match.Length;
|
||||
}
|
||||
|
||||
if (lastIndex < line.Length)
|
||||
{
|
||||
paragraph.Inlines.Add(new Run(line.Substring(lastIndex)));
|
||||
}
|
||||
|
||||
LogRichTextBox.Document.Blocks.Add(paragraph);
|
||||
}
|
||||
}
|
||||
|
||||
private string BuildExportContent()
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
builder.AppendLine("Лабораторная работа №9. Внутренняя сортировка данных");
|
||||
builder.AppendLine($"Исходный массив: {string.Join(", ", _currentArray)}");
|
||||
builder.AppendLine($"Режим сортировки: {(DescendingCheckBox.IsChecked == true ? "По убыванию" : "По возрастанию")}");
|
||||
|
||||
if (_lastResult is null)
|
||||
{
|
||||
builder.AppendLine("Сортировка ещё не запускалась.");
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
builder.AppendLine($"Алгоритм: {_lastResult.AlgorithmName}");
|
||||
builder.AppendLine($"Отсортированный массив: {string.Join(", ", _lastResult.SortedArray)}");
|
||||
builder.AppendLine($"Количество сравнений: {_lastResult.Metrics.Comparisons}");
|
||||
builder.AppendLine($"Количество пересылок: {_lastResult.Metrics.Moves}");
|
||||
builder.AppendLine($"Время сортировки: {_lastResult.Elapsed.TotalMilliseconds:F6} мс");
|
||||
builder.AppendLine();
|
||||
builder.AppendLine("Пошаговый журнал:");
|
||||
builder.AppendLine(_lastResult.Log);
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Models/AnalysisRow.cs
Normal file
12
Models/AnalysisRow.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Lab9.Models;
|
||||
|
||||
public class AnalysisRow
|
||||
{
|
||||
public int ElementCount { get; set; }
|
||||
|
||||
public string TimSort { get; set; } = string.Empty;
|
||||
|
||||
public string Msd { get; set; } = string.Empty;
|
||||
|
||||
public string Communist { get; set; } = string.Empty;
|
||||
}
|
||||
12
Models/SortMetrics.cs
Normal file
12
Models/SortMetrics.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Lab9.Models;
|
||||
|
||||
public class SortMetrics
|
||||
{
|
||||
public long Comparisons { get; private set; }
|
||||
|
||||
public long Moves { get; private set; }
|
||||
|
||||
public void AddComparison(long count = 1) => Comparisons += count;
|
||||
|
||||
public void AddMove(long count = 1) => Moves += count;
|
||||
}
|
||||
14
Models/SortResult.cs
Normal file
14
Models/SortResult.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace Lab9.Models;
|
||||
|
||||
public class SortResult
|
||||
{
|
||||
public required string AlgorithmName { get; init; }
|
||||
|
||||
public required int[] SortedArray { get; init; }
|
||||
|
||||
public required SortMetrics Metrics { get; init; }
|
||||
|
||||
public required TimeSpan Elapsed { get; init; }
|
||||
|
||||
public required string Log { get; init; }
|
||||
}
|
||||
18
Services/ArrayIoService.cs
Normal file
18
Services/ArrayIoService.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.IO;
|
||||
|
||||
namespace Lab9.Services;
|
||||
|
||||
public static class ArrayIoService
|
||||
{
|
||||
private static readonly char[] Separators = [' ', ',', ';', '\n', '\r', '\t'];
|
||||
|
||||
public static int[] ReadArrayFromFile(string filePath)
|
||||
{
|
||||
var content = File.ReadAllText(filePath);
|
||||
|
||||
return content
|
||||
.Split(Separators, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(int.Parse)
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
25
Services/SortingContext.cs
Normal file
25
Services/SortingContext.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Lab9.Models;
|
||||
using Lab9.Strategies;
|
||||
|
||||
namespace Lab9.Services;
|
||||
|
||||
public class SortingContext
|
||||
{
|
||||
public SortingContext()
|
||||
{
|
||||
}
|
||||
|
||||
public SortingContext(ISortStrategy strategy)
|
||||
{
|
||||
ContextStrategy = strategy;
|
||||
}
|
||||
|
||||
public ISortStrategy? ContextStrategy { get; set; }
|
||||
|
||||
public SortResult Execute(int[] array, bool ascending, bool enableLogging)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(ContextStrategy);
|
||||
|
||||
return ContextStrategy.Sort(array, ascending, enableLogging);
|
||||
}
|
||||
}
|
||||
40
Services/StepLogger.cs
Normal file
40
Services/StepLogger.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Text;
|
||||
|
||||
namespace Lab9.Services;
|
||||
|
||||
public class StepLogger
|
||||
{
|
||||
private readonly StringBuilder _builder = new();
|
||||
|
||||
public void Header(string text)
|
||||
{
|
||||
_builder.AppendLine(text);
|
||||
}
|
||||
|
||||
public void BlankLine()
|
||||
{
|
||||
_builder.AppendLine();
|
||||
}
|
||||
|
||||
public void Line(string text)
|
||||
{
|
||||
_builder.AppendLine(text);
|
||||
}
|
||||
|
||||
public void ArrayState(int[] array, params int[] highlightedIndices)
|
||||
{
|
||||
var highlighted = highlightedIndices.Length == 0
|
||||
? new HashSet<int>()
|
||||
: highlightedIndices.ToHashSet();
|
||||
|
||||
var parts = new string[array.Length];
|
||||
for (var i = 0; i < array.Length; i++)
|
||||
{
|
||||
parts[i] = highlighted.Contains(i) ? $"[{array[i]}]" : array[i].ToString();
|
||||
}
|
||||
|
||||
_builder.AppendLine(string.Join(" ", parts));
|
||||
}
|
||||
|
||||
public override string ToString() => _builder.ToString();
|
||||
}
|
||||
31
Strategies/CommunistSortStrategy.cs
Normal file
31
Strategies/CommunistSortStrategy.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Lab9.Models;
|
||||
using Lab9.Services;
|
||||
|
||||
namespace Lab9.Strategies;
|
||||
|
||||
public class CommunistSortStrategy : SortStrategyBase
|
||||
{
|
||||
public override string Name => "Коммунистическая сортировка";
|
||||
|
||||
protected override void ExecuteCore(int[] array, SortMetrics metrics, StepLogger? logger)
|
||||
{
|
||||
if (array.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var average = (int)(array.Sum(x => (long)x) / array.Length);
|
||||
|
||||
logger?.Line($"Среднее значение массива: {average}.");
|
||||
logger?.Line("Последовательно приводим элементы массива к общему значению.");
|
||||
logger?.BlankLine();
|
||||
|
||||
for (var i = 0; i < array.Length; i++)
|
||||
{
|
||||
var oldValue = array[i];
|
||||
logger?.Line($"Уравниваем индекс {i}: {oldValue} -> {average}.");
|
||||
Assign(array, i, average, metrics);
|
||||
logger?.ArrayState(array, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Strategies/ISortStrategy.cs
Normal file
10
Strategies/ISortStrategy.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Lab9.Models;
|
||||
|
||||
namespace Lab9.Strategies;
|
||||
|
||||
public interface ISortStrategy
|
||||
{
|
||||
string Name { get; }
|
||||
|
||||
SortResult Sort(int[] source, bool ascending, bool enableLogging);
|
||||
}
|
||||
94
Strategies/MsdRadixSortStrategy.cs
Normal file
94
Strategies/MsdRadixSortStrategy.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using Lab9.Models;
|
||||
using Lab9.Services;
|
||||
|
||||
namespace Lab9.Strategies;
|
||||
|
||||
public class MsdRadixSortStrategy : SortStrategyBase
|
||||
{
|
||||
private const int AlphabetSize = 256;
|
||||
private const int Cutoff = 16;
|
||||
|
||||
public override string Name => "MSD Radix Sort";
|
||||
|
||||
protected override void ExecuteCore(int[] array, SortMetrics metrics, StepLogger? logger)
|
||||
{
|
||||
if (array.Length <= 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var aux = new int[array.Length];
|
||||
Sort(array, 0, array.Length - 1, 3, aux, metrics, logger);
|
||||
}
|
||||
|
||||
private static void Sort(
|
||||
int[] array,
|
||||
int left,
|
||||
int right,
|
||||
int byteIndex,
|
||||
int[] aux,
|
||||
SortMetrics metrics,
|
||||
StepLogger? logger)
|
||||
{
|
||||
if (right <= left || byteIndex < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (right - left <= Cutoff)
|
||||
{
|
||||
logger?.Line($"MSD: маленький диапазон [{left}; {right}], переключаемся на сортировку вставками.");
|
||||
InsertionSortRange(array, left, right, metrics, logger, "MSD/Insertion");
|
||||
logger?.BlankLine();
|
||||
return;
|
||||
}
|
||||
|
||||
logger?.Line($"MSD: обрабатываем диапазон [{left}; {right}], байт №{byteIndex}.");
|
||||
var count = new int[AlphabetSize + 2];
|
||||
|
||||
for (var i = left; i <= right; i++)
|
||||
{
|
||||
var digit = GetByte(array[i], byteIndex);
|
||||
count[digit + 2]++;
|
||||
}
|
||||
|
||||
for (var r = 0; r < AlphabetSize + 1; r++)
|
||||
{
|
||||
count[r + 1] += count[r];
|
||||
}
|
||||
|
||||
var starts = count.ToArray();
|
||||
|
||||
for (var i = left; i <= right; i++)
|
||||
{
|
||||
var digit = GetByte(array[i], byteIndex);
|
||||
aux[count[digit + 1]++] = array[i];
|
||||
metrics.AddMove();
|
||||
}
|
||||
|
||||
for (var i = left; i <= right; i++)
|
||||
{
|
||||
Assign(array, i, aux[i - left], metrics);
|
||||
}
|
||||
|
||||
logger?.ArrayState(array);
|
||||
logger?.BlankLine();
|
||||
|
||||
for (var r = 0; r < AlphabetSize; r++)
|
||||
{
|
||||
var start = left + starts[r];
|
||||
var end = left + starts[r + 1] - 1;
|
||||
|
||||
if (start < end)
|
||||
{
|
||||
Sort(array, start, end, byteIndex - 1, aux, metrics, logger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static int GetByte(int value, int byteIndex)
|
||||
{
|
||||
var normalized = unchecked((uint)(value ^ int.MinValue));
|
||||
return (int)((normalized >> (byteIndex * 8)) & 0xFF);
|
||||
}
|
||||
}
|
||||
117
Strategies/SortStrategyBase.cs
Normal file
117
Strategies/SortStrategyBase.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using Lab9.Models;
|
||||
using Lab9.Services;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Lab9.Strategies;
|
||||
|
||||
public abstract class SortStrategyBase : ISortStrategy
|
||||
{
|
||||
public abstract string Name { get; }
|
||||
|
||||
public SortResult Sort(int[] source, bool ascending, bool enableLogging)
|
||||
{
|
||||
var array = source.ToArray();
|
||||
var metrics = new SortMetrics();
|
||||
var logger = enableLogging ? new StepLogger() : null;
|
||||
|
||||
logger?.Header($"Алгоритм: {Name}");
|
||||
logger?.Line($"Режим: {(ascending ? "По возрастанию" : "По убыванию")}");
|
||||
logger?.Line("Исходное состояние массива:");
|
||||
logger?.ArrayState(array);
|
||||
logger?.BlankLine();
|
||||
|
||||
var stopwatch = Stopwatch.StartNew();
|
||||
ExecuteCore(array, metrics, logger);
|
||||
|
||||
if (!ascending && array.Length > 1)
|
||||
{
|
||||
logger?.Line("Дополнительный этап: разворот массива для режима по убыванию.");
|
||||
Reverse(array, 0, array.Length - 1, metrics, logger);
|
||||
logger?.ArrayState(array);
|
||||
logger?.BlankLine();
|
||||
}
|
||||
|
||||
stopwatch.Stop();
|
||||
|
||||
logger?.Line("Финальный результат:");
|
||||
logger?.ArrayState(array);
|
||||
|
||||
return new SortResult
|
||||
{
|
||||
AlgorithmName = Name,
|
||||
SortedArray = array,
|
||||
Metrics = metrics,
|
||||
Elapsed = stopwatch.Elapsed,
|
||||
Log = logger?.ToString() ?? string.Empty
|
||||
};
|
||||
}
|
||||
|
||||
protected abstract void ExecuteCore(int[] array, SortMetrics metrics, StepLogger? logger);
|
||||
|
||||
protected static int Compare(int left, int right, SortMetrics metrics)
|
||||
{
|
||||
metrics.AddComparison();
|
||||
return left.CompareTo(right);
|
||||
}
|
||||
|
||||
protected static void Assign(int[] array, int index, int value, SortMetrics metrics)
|
||||
{
|
||||
array[index] = value;
|
||||
metrics.AddMove();
|
||||
}
|
||||
|
||||
protected static void Swap(int[] array, int left, int right, SortMetrics metrics)
|
||||
{
|
||||
if (left == right)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
(array[left], array[right]) = (array[right], array[left]);
|
||||
metrics.AddMove(3);
|
||||
}
|
||||
|
||||
protected static void Reverse(int[] array, int left, int right, SortMetrics metrics, StepLogger? logger)
|
||||
{
|
||||
while (left < right)
|
||||
{
|
||||
logger?.Line($"Меняем местами {array[left]} и {array[right]}.");
|
||||
|
||||
Swap(array, left, right, metrics);
|
||||
logger?.ArrayState(array, left, right);
|
||||
|
||||
left++;
|
||||
right--;
|
||||
}
|
||||
}
|
||||
|
||||
protected static void InsertionSortRange(
|
||||
int[] array,
|
||||
int left,
|
||||
int right,
|
||||
SortMetrics metrics,
|
||||
StepLogger? logger,
|
||||
string prefix)
|
||||
{
|
||||
for (var i = left + 1; i <= right; i++)
|
||||
{
|
||||
var current = array[i];
|
||||
var j = i - 1;
|
||||
|
||||
logger?.Line($"{prefix}: берём элемент {current}.");
|
||||
|
||||
while (j >= left && Compare(array[j], current, metrics) > 0)
|
||||
{
|
||||
logger?.Line($"Сравниваем {array[j]} и {current}. Сдвигаем {array[j]} вправо.");
|
||||
|
||||
Assign(array, j + 1, array[j], metrics);
|
||||
logger?.ArrayState(array, j, j + 1);
|
||||
j--;
|
||||
}
|
||||
|
||||
logger?.Line($"Ставим элемент {current} на место.");
|
||||
Assign(array, j + 1, current, metrics);
|
||||
logger?.ArrayState(array, j + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
758
Strategies/TimSortStrategy.cs
Normal file
758
Strategies/TimSortStrategy.cs
Normal file
@@ -0,0 +1,758 @@
|
||||
using Lab9.Models;
|
||||
using Lab9.Services;
|
||||
|
||||
namespace Lab9.Strategies;
|
||||
|
||||
public class TimSortStrategy : SortStrategyBase
|
||||
{
|
||||
private const int MinMerge = 32;
|
||||
private const int InitialMinGallop = 7;
|
||||
|
||||
private int[] _array = Array.Empty<int>();
|
||||
private int[] _temp = Array.Empty<int>();
|
||||
private int _minGallop;
|
||||
private readonly List<RunInfo> _runs = new();
|
||||
|
||||
private SortMetrics? _metrics;
|
||||
private StepLogger? _logger;
|
||||
|
||||
private struct RunInfo
|
||||
{
|
||||
public int Base;
|
||||
public int Length;
|
||||
|
||||
public RunInfo(int runBase, int runLength)
|
||||
{
|
||||
Base = runBase;
|
||||
Length = runLength;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Name => "TimSort";
|
||||
|
||||
protected override void ExecuteCore(int[] array, SortMetrics metrics, StepLogger? logger)
|
||||
{
|
||||
if (array.Length <= 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_array = array;
|
||||
_metrics = metrics;
|
||||
_logger = logger;
|
||||
_minGallop = InitialMinGallop;
|
||||
_runs.Clear();
|
||||
_temp = Array.Empty<int>();
|
||||
|
||||
var minRun = MinRunLength(array.Length);
|
||||
|
||||
logger?.Line($"TimSort: вычисленный minrun = {minRun}.");
|
||||
logger?.BlankLine();
|
||||
|
||||
var lo = 0;
|
||||
var remaining = array.Length;
|
||||
|
||||
while (remaining > 0)
|
||||
{
|
||||
var runLength = CountRunAndMakeAscending(lo, array.Length);
|
||||
|
||||
logger?.Line($"Найдена серия [{lo}; {lo + runLength - 1}] длиной {runLength}.");
|
||||
|
||||
if (runLength < minRun)
|
||||
{
|
||||
var forcedLength = remaining <= minRun ? remaining : minRun;
|
||||
logger?.Line($"Увеличиваем серию до {forcedLength} бинарными вставками.");
|
||||
BinaryInsertionSort(lo, lo + forcedLength, lo + runLength);
|
||||
runLength = forcedLength;
|
||||
logger?.ArrayState(_array);
|
||||
}
|
||||
|
||||
PushRun(lo, runLength);
|
||||
MergeCollapse();
|
||||
|
||||
lo += runLength;
|
||||
remaining -= runLength;
|
||||
|
||||
logger?.BlankLine();
|
||||
}
|
||||
|
||||
MergeForceCollapse();
|
||||
}
|
||||
|
||||
private static int MinRunLength(int n)
|
||||
{
|
||||
var r = 0;
|
||||
|
||||
while (n >= MinMerge)
|
||||
{
|
||||
r |= n & 1;
|
||||
n >>= 1;
|
||||
}
|
||||
|
||||
return n + r;
|
||||
}
|
||||
|
||||
private int CountRunAndMakeAscending(int lo, int hi)
|
||||
{
|
||||
var metrics = _metrics!;
|
||||
var logger = _logger;
|
||||
|
||||
var runHi = lo + 1;
|
||||
if (runHi == hi)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (Compare(_array[runHi], _array[lo], metrics) < 0)
|
||||
{
|
||||
runHi++;
|
||||
|
||||
while (runHi < hi && Compare(_array[runHi], _array[runHi - 1], metrics) < 0)
|
||||
{
|
||||
runHi++;
|
||||
}
|
||||
|
||||
logger?.Line($"Серия [{lo}; {runHi - 1}] убывающая. Разворачиваем.");
|
||||
Reverse(_array, lo, runHi - 1, metrics, logger);
|
||||
}
|
||||
else
|
||||
{
|
||||
runHi++;
|
||||
|
||||
while (runHi < hi && Compare(_array[runHi], _array[runHi - 1], metrics) >= 0)
|
||||
{
|
||||
runHi++;
|
||||
}
|
||||
}
|
||||
|
||||
return runHi - lo;
|
||||
}
|
||||
|
||||
private void BinaryInsertionSort(int lo, int hi, int start)
|
||||
{
|
||||
var metrics = _metrics!;
|
||||
var logger = _logger;
|
||||
|
||||
if (start == lo)
|
||||
{
|
||||
start++;
|
||||
}
|
||||
|
||||
for (var i = start; i < hi; i++)
|
||||
{
|
||||
var pivot = _array[i];
|
||||
var left = lo;
|
||||
var right = i;
|
||||
|
||||
while (left < right)
|
||||
{
|
||||
var mid = left + ((right - left) >> 1);
|
||||
|
||||
if (Compare(pivot, _array[mid], metrics) < 0)
|
||||
{
|
||||
right = mid;
|
||||
}
|
||||
else
|
||||
{
|
||||
left = mid + 1;
|
||||
}
|
||||
}
|
||||
|
||||
logger?.Line($"Вставляем элемент {pivot} на позицию {left}.");
|
||||
|
||||
for (var j = i; j > left; j--)
|
||||
{
|
||||
Assign(_array, j, _array[j - 1], metrics);
|
||||
}
|
||||
|
||||
Assign(_array, left, pivot, metrics);
|
||||
logger?.ArrayState(_array, left);
|
||||
}
|
||||
}
|
||||
|
||||
private void PushRun(int runBase, int runLength)
|
||||
{
|
||||
_runs.Add(new RunInfo(runBase, runLength));
|
||||
}
|
||||
|
||||
private void MergeCollapse()
|
||||
{
|
||||
while (_runs.Count > 1)
|
||||
{
|
||||
var n = _runs.Count - 2;
|
||||
|
||||
if (n > 0 && _runs[n - 1].Length <= _runs[n].Length + _runs[n + 1].Length)
|
||||
{
|
||||
if (_runs[n - 1].Length < _runs[n + 1].Length)
|
||||
{
|
||||
n--;
|
||||
}
|
||||
|
||||
MergeAt(n);
|
||||
}
|
||||
else if (_runs[n].Length <= _runs[n + 1].Length)
|
||||
{
|
||||
MergeAt(n);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MergeForceCollapse()
|
||||
{
|
||||
while (_runs.Count > 1)
|
||||
{
|
||||
var n = _runs.Count - 2;
|
||||
|
||||
if (n > 0 && _runs[n - 1].Length < _runs[n + 1].Length)
|
||||
{
|
||||
n--;
|
||||
}
|
||||
|
||||
MergeAt(n);
|
||||
}
|
||||
}
|
||||
|
||||
private void MergeAt(int index)
|
||||
{
|
||||
var metrics = _metrics!;
|
||||
var logger = _logger;
|
||||
|
||||
var base1 = _runs[index].Base;
|
||||
var len1 = _runs[index].Length;
|
||||
var base2 = _runs[index + 1].Base;
|
||||
var len2 = _runs[index + 1].Length;
|
||||
|
||||
logger?.Line(
|
||||
$"Сливаем серии [{base1}; {base1 + len1 - 1}] и [{base2}; {base2 + len2 - 1}].");
|
||||
|
||||
_runs[index] = new RunInfo(base1, len1 + len2);
|
||||
_runs.RemoveAt(index + 1);
|
||||
|
||||
var k = GallopRight(_array[base2], _array, base1, len1, 0, metrics);
|
||||
base1 += k;
|
||||
len1 -= k;
|
||||
|
||||
if (len1 == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
len2 = GallopLeft(_array[base1 + len1 - 1], _array, base2, len2, len2 - 1, metrics);
|
||||
|
||||
if (len2 == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (len1 <= len2)
|
||||
{
|
||||
MergeLo(base1, len1, base2, len2);
|
||||
}
|
||||
else
|
||||
{
|
||||
MergeHi(base1, len1, base2, len2);
|
||||
}
|
||||
|
||||
logger?.ArrayState(_array);
|
||||
}
|
||||
|
||||
private void MergeLo(int base1, int len1, int base2, int len2)
|
||||
{
|
||||
var metrics = _metrics!;
|
||||
|
||||
EnsureCapacity(len1);
|
||||
Array.Copy(_array, base1, _temp, 0, len1);
|
||||
metrics.AddMove(len1);
|
||||
|
||||
var cursor1 = 0;
|
||||
var cursor2 = base2;
|
||||
var dest = base1;
|
||||
|
||||
Assign(_array, dest++, _array[cursor2++], metrics);
|
||||
len2--;
|
||||
|
||||
if (len2 == 0)
|
||||
{
|
||||
Array.Copy(_temp, cursor1, _array, dest, len1);
|
||||
metrics.AddMove(len1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (len1 == 1)
|
||||
{
|
||||
Array.Copy(_array, cursor2, _array, dest, len2);
|
||||
metrics.AddMove(len2);
|
||||
Assign(_array, dest + len2, _temp[cursor1], metrics);
|
||||
return;
|
||||
}
|
||||
|
||||
var minGallop = _minGallop;
|
||||
|
||||
while (true)
|
||||
{
|
||||
var count1 = 0;
|
||||
var count2 = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if (Compare(_array[cursor2], _temp[cursor1], metrics) < 0)
|
||||
{
|
||||
Assign(_array, dest++, _array[cursor2++], metrics);
|
||||
count2++;
|
||||
count1 = 0;
|
||||
len2--;
|
||||
|
||||
if (len2 == 0)
|
||||
{
|
||||
Array.Copy(_temp, cursor1, _array, dest, len1);
|
||||
metrics.AddMove(len1);
|
||||
_minGallop = Math.Max(minGallop, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Assign(_array, dest++, _temp[cursor1++], metrics);
|
||||
count1++;
|
||||
count2 = 0;
|
||||
len1--;
|
||||
|
||||
if (len1 == 1)
|
||||
{
|
||||
Array.Copy(_array, cursor2, _array, dest, len2);
|
||||
metrics.AddMove(len2);
|
||||
Assign(_array, dest + len2, _temp[cursor1], metrics);
|
||||
_minGallop = Math.Max(minGallop, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
while ((count1 | count2) < minGallop);
|
||||
|
||||
do
|
||||
{
|
||||
count1 = GallopRight(_array[cursor2], _temp, cursor1, len1, 0, metrics);
|
||||
|
||||
if (count1 != 0)
|
||||
{
|
||||
Array.Copy(_temp, cursor1, _array, dest, count1);
|
||||
metrics.AddMove(count1);
|
||||
dest += count1;
|
||||
cursor1 += count1;
|
||||
len1 -= count1;
|
||||
|
||||
if (len1 <= 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Assign(_array, dest++, _array[cursor2++], metrics);
|
||||
len2--;
|
||||
|
||||
if (len2 == 0)
|
||||
{
|
||||
Array.Copy(_temp, cursor1, _array, dest, len1);
|
||||
metrics.AddMove(len1);
|
||||
_minGallop = Math.Max(minGallop, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
count2 = GallopLeft(_temp[cursor1], _array, cursor2, len2, 0, metrics);
|
||||
|
||||
if (count2 != 0)
|
||||
{
|
||||
Array.Copy(_array, cursor2, _array, dest, count2);
|
||||
metrics.AddMove(count2);
|
||||
dest += count2;
|
||||
cursor2 += count2;
|
||||
len2 -= count2;
|
||||
|
||||
if (len2 == 0)
|
||||
{
|
||||
Array.Copy(_temp, cursor1, _array, dest, len1);
|
||||
metrics.AddMove(len1);
|
||||
_minGallop = Math.Max(minGallop, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Assign(_array, dest++, _temp[cursor1++], metrics);
|
||||
len1--;
|
||||
|
||||
if (len1 == 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
minGallop--;
|
||||
}
|
||||
while (count1 >= InitialMinGallop || count2 >= InitialMinGallop);
|
||||
|
||||
if (minGallop < 1)
|
||||
{
|
||||
minGallop = 1;
|
||||
}
|
||||
|
||||
minGallop += 2;
|
||||
|
||||
if (len1 <= 1 || len2 == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_minGallop = Math.Max(minGallop, 1);
|
||||
|
||||
if (len1 == 1)
|
||||
{
|
||||
Array.Copy(_array, cursor2, _array, dest, len2);
|
||||
metrics.AddMove(len2);
|
||||
Assign(_array, dest + len2, _temp[cursor1], metrics);
|
||||
}
|
||||
else if (len1 > 1)
|
||||
{
|
||||
Array.Copy(_temp, cursor1, _array, dest, len1);
|
||||
metrics.AddMove(len1);
|
||||
}
|
||||
}
|
||||
|
||||
private void MergeHi(int base1, int len1, int base2, int len2)
|
||||
{
|
||||
var metrics = _metrics!;
|
||||
|
||||
EnsureCapacity(len2);
|
||||
Array.Copy(_array, base2, _temp, 0, len2);
|
||||
metrics.AddMove(len2);
|
||||
|
||||
var cursor1 = base1 + len1 - 1;
|
||||
var cursor2 = len2 - 1;
|
||||
var dest = base2 + len2 - 1;
|
||||
|
||||
Assign(_array, dest--, _array[cursor1--], metrics);
|
||||
len1--;
|
||||
|
||||
if (len1 == 0)
|
||||
{
|
||||
Array.Copy(_temp, 0, _array, dest - (len2 - 1), len2);
|
||||
metrics.AddMove(len2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (len2 == 1)
|
||||
{
|
||||
dest -= len1;
|
||||
cursor1 -= len1;
|
||||
Array.Copy(_array, cursor1 + 1, _array, dest + 1, len1);
|
||||
metrics.AddMove(len1);
|
||||
Assign(_array, dest, _temp[cursor2], metrics);
|
||||
return;
|
||||
}
|
||||
|
||||
var minGallop = _minGallop;
|
||||
|
||||
while (true)
|
||||
{
|
||||
var count1 = 0;
|
||||
var count2 = 0;
|
||||
|
||||
do
|
||||
{
|
||||
if (Compare(_temp[cursor2], _array[cursor1], metrics) < 0)
|
||||
{
|
||||
Assign(_array, dest--, _array[cursor1--], metrics);
|
||||
count1++;
|
||||
count2 = 0;
|
||||
len1--;
|
||||
|
||||
if (len1 == 0)
|
||||
{
|
||||
Array.Copy(_temp, 0, _array, dest - (len2 - 1), len2);
|
||||
metrics.AddMove(len2);
|
||||
_minGallop = Math.Max(minGallop, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Assign(_array, dest--, _temp[cursor2--], metrics);
|
||||
count2++;
|
||||
count1 = 0;
|
||||
len2--;
|
||||
|
||||
if (len2 == 1)
|
||||
{
|
||||
dest -= len1;
|
||||
cursor1 -= len1;
|
||||
Array.Copy(_array, cursor1 + 1, _array, dest + 1, len1);
|
||||
metrics.AddMove(len1);
|
||||
Assign(_array, dest, _temp[cursor2], metrics);
|
||||
_minGallop = Math.Max(minGallop, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
while ((count1 | count2) < minGallop);
|
||||
|
||||
do
|
||||
{
|
||||
count1 = len1 - GallopRight(_temp[cursor2], _array, base1, len1, len1 - 1, metrics);
|
||||
|
||||
if (count1 != 0)
|
||||
{
|
||||
dest -= count1;
|
||||
cursor1 -= count1;
|
||||
len1 -= count1;
|
||||
|
||||
Array.Copy(_array, cursor1 + 1, _array, dest + 1, count1);
|
||||
metrics.AddMove(count1);
|
||||
|
||||
if (len1 == 0)
|
||||
{
|
||||
Array.Copy(_temp, 0, _array, dest - (len2 - 1), len2);
|
||||
metrics.AddMove(len2);
|
||||
_minGallop = Math.Max(minGallop, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Assign(_array, dest--, _temp[cursor2--], metrics);
|
||||
len2--;
|
||||
|
||||
if (len2 == 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
count2 = len2 - GallopLeft(_array[cursor1], _temp, 0, len2, len2 - 1, metrics);
|
||||
|
||||
if (count2 != 0)
|
||||
{
|
||||
dest -= count2;
|
||||
cursor2 -= count2;
|
||||
len2 -= count2;
|
||||
|
||||
Array.Copy(_temp, cursor2 + 1, _array, dest + 1, count2);
|
||||
metrics.AddMove(count2);
|
||||
|
||||
if (len2 <= 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Assign(_array, dest--, _array[cursor1--], metrics);
|
||||
len1--;
|
||||
|
||||
if (len1 == 0)
|
||||
{
|
||||
Array.Copy(_temp, 0, _array, dest - (len2 - 1), len2);
|
||||
metrics.AddMove(len2);
|
||||
_minGallop = Math.Max(minGallop, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
minGallop--;
|
||||
}
|
||||
while (count1 >= InitialMinGallop || count2 >= InitialMinGallop);
|
||||
|
||||
if (minGallop < 1)
|
||||
{
|
||||
minGallop = 1;
|
||||
}
|
||||
|
||||
minGallop += 2;
|
||||
|
||||
if (len1 == 0 || len2 <= 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_minGallop = Math.Max(minGallop, 1);
|
||||
|
||||
if (len2 == 1)
|
||||
{
|
||||
dest -= len1;
|
||||
cursor1 -= len1;
|
||||
Array.Copy(_array, cursor1 + 1, _array, dest + 1, len1);
|
||||
metrics.AddMove(len1);
|
||||
Assign(_array, dest, _temp[cursor2], metrics);
|
||||
}
|
||||
else if (len2 > 1)
|
||||
{
|
||||
Array.Copy(_temp, 0, _array, dest - (len2 - 1), len2);
|
||||
metrics.AddMove(len2);
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureCapacity(int minCapacity)
|
||||
{
|
||||
if (_temp.Length >= minCapacity)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_temp = new int[minCapacity];
|
||||
}
|
||||
|
||||
private static int GallopLeft(
|
||||
int key,
|
||||
int[] array,
|
||||
int baseIndex,
|
||||
int length,
|
||||
int hint,
|
||||
SortMetrics metrics)
|
||||
{
|
||||
var lastOffset = 0;
|
||||
var offset = 1;
|
||||
|
||||
if (Compare(key, array[baseIndex + hint], metrics) > 0)
|
||||
{
|
||||
var maxOffset = length - hint;
|
||||
|
||||
while (offset < maxOffset && Compare(key, array[baseIndex + hint + offset], metrics) > 0)
|
||||
{
|
||||
lastOffset = offset;
|
||||
offset = (offset << 1) + 1;
|
||||
|
||||
if (offset <= 0)
|
||||
{
|
||||
offset = maxOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if (offset > maxOffset)
|
||||
{
|
||||
offset = maxOffset;
|
||||
}
|
||||
|
||||
lastOffset += hint;
|
||||
offset += hint;
|
||||
}
|
||||
else
|
||||
{
|
||||
var maxOffset = hint + 1;
|
||||
|
||||
while (offset < maxOffset && Compare(key, array[baseIndex + hint - offset], metrics) <= 0)
|
||||
{
|
||||
lastOffset = offset;
|
||||
offset = (offset << 1) + 1;
|
||||
|
||||
if (offset <= 0)
|
||||
{
|
||||
offset = maxOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if (offset > maxOffset)
|
||||
{
|
||||
offset = maxOffset;
|
||||
}
|
||||
|
||||
var temp = lastOffset;
|
||||
lastOffset = hint - offset;
|
||||
offset = hint - temp;
|
||||
}
|
||||
|
||||
lastOffset++;
|
||||
|
||||
while (lastOffset < offset)
|
||||
{
|
||||
var middle = lastOffset + ((offset - lastOffset) >> 1);
|
||||
|
||||
if (Compare(key, array[baseIndex + middle], metrics) > 0)
|
||||
{
|
||||
lastOffset = middle + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = middle;
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
private static int GallopRight(
|
||||
int key,
|
||||
int[] array,
|
||||
int baseIndex,
|
||||
int length,
|
||||
int hint,
|
||||
SortMetrics metrics)
|
||||
{
|
||||
var offset = 1;
|
||||
var lastOffset = 0;
|
||||
|
||||
if (Compare(key, array[baseIndex + hint], metrics) < 0)
|
||||
{
|
||||
var maxOffset = hint + 1;
|
||||
|
||||
while (offset < maxOffset && Compare(key, array[baseIndex + hint - offset], metrics) < 0)
|
||||
{
|
||||
lastOffset = offset;
|
||||
offset = (offset << 1) + 1;
|
||||
|
||||
if (offset <= 0)
|
||||
{
|
||||
offset = maxOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if (offset > maxOffset)
|
||||
{
|
||||
offset = maxOffset;
|
||||
}
|
||||
|
||||
var temp = lastOffset;
|
||||
lastOffset = hint - offset;
|
||||
offset = hint - temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
var maxOffset = length - hint;
|
||||
|
||||
while (offset < maxOffset && Compare(key, array[baseIndex + hint + offset], metrics) >= 0)
|
||||
{
|
||||
lastOffset = offset;
|
||||
offset = (offset << 1) + 1;
|
||||
|
||||
if (offset <= 0)
|
||||
{
|
||||
offset = maxOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if (offset > maxOffset)
|
||||
{
|
||||
offset = maxOffset;
|
||||
}
|
||||
|
||||
lastOffset += hint;
|
||||
offset += hint;
|
||||
}
|
||||
|
||||
lastOffset++;
|
||||
|
||||
while (lastOffset < offset)
|
||||
{
|
||||
var middle = lastOffset + ((offset - lastOffset) >> 1);
|
||||
|
||||
if (Compare(key, array[baseIndex + middle], metrics) < 0)
|
||||
{
|
||||
offset = middle;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastOffset = middle + 1;
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
}
|
||||
1
sample_input.txt
Normal file
1
sample_input.txt
Normal file
@@ -0,0 +1 @@
|
||||
15, 33, 42, 7, 12, 19
|
||||
195
sorting_result.txt
Normal file
195
sorting_result.txt
Normal file
@@ -0,0 +1,195 @@
|
||||
Лабораторная работа №9. Внутренняя сортировка данных
|
||||
Исходный массив: 59, 183, 240, 189, -219, -13, 407, 532, 731, 237, 30, -112, 791, -213, 977, 585, 801, 945, 481, 822, -153, 640, 253, 279, 830, 147, 680, 373, 533, -116, 652, 506, 664, 535, -243, 389, 843, 457, 802, 322, 426, 204, 833, 515, 555, -154, -59, 54, -42, 899, 83, 288, 222, 549, -110, 804, 471, 612, 578, 19, 840, 695, 876, 691, 398, 551, 323, 587, 225, 132, -106, 486, -249, 684, -107, -214, 609, 895, 50, 72, 940, 568, -87, 760, 815, 50, 743, -167, 389, -42, -133, 823, 145, 991, 432, 678, 912, -222, 886, 333, 359, 168, 605, 722, -88, 467, 166, 310, 649, 118, -56, 148, 221, 643, -220, 601, 56, 867, 467, 988, 917, 716, 535, -146, 431, 549, 665, 636, 388, -47, 606, 407, 180, 169, 962, 372, 6, -103, 356, 308, 618, -85, -203, -172, -70, 349, 357, 141, 128, 175
|
||||
Режим сортировки: По убыванию
|
||||
Алгоритм: MSD Radix Sort
|
||||
Отсортированный массив: 991, 988, 977, 962, 945, 940, 917, 912, 899, 895, 886, 876, 867, 843, 840, 833, 830, 823, 822, 815, 804, 802, 801, 791, 760, 743, 731, 722, 716, 695, 691, 684, 680, 678, 665, 664, 652, 649, 643, 640, 636, 618, 612, 609, 606, 605, 601, 587, 585, 578, 568, 555, 551, 549, 549, 535, 535, 533, 532, 515, 506, 486, 481, 471, 467, 467, 457, 432, 431, 426, 407, 407, 398, 389, 389, 388, 373, 372, 359, 357, 356, 349, 333, 323, 322, 310, 308, 288, 279, 253, 240, 237, 225, 222, 221, 204, 189, 183, 180, 175, 169, 168, 166, 148, 147, 145, 141, 132, 128, 118, 83, 72, 59, 56, 54, 50, 50, 30, 19, 6, -70, -172, -203, -85, -103, -47, -146, -220, -56, -88, -222, -133, -42, -167, -87, -214, -107, -249, -106, -110, -42, -59, -154, -243, -116, -153, -213, -112, -13, -219
|
||||
Количество сравнений: 0
|
||||
Количество пересылок: 1305
|
||||
Время сортировки: 0.761900 мс
|
||||
|
||||
Пошаговый журнал:
|
||||
Алгоритм: MSD Radix Sort
|
||||
Режим: По убыванию
|
||||
Исходное состояние массива:
|
||||
59 183 240 189 -219 -13 407 532 731 237 30 -112 791 -213 977 585 801 945 481 822 -153 640 253 279 830 147 680 373 533 -116 652 506 664 535 -243 389 843 457 802 322 426 204 833 515 555 -154 -59 54 -42 899 83 288 222 549 -110 804 471 612 578 19 840 695 876 691 398 551 323 587 225 132 -106 486 -249 684 -107 -214 609 895 50 72 940 568 -87 760 815 50 743 -167 389 -42 -133 823 145 991 432 678 912 -222 886 333 359 168 605 722 -88 467 166 310 649 118 -56 148 221 643 -220 601 56 867 467 988 917 716 535 -146 431 549 665 636 388 -47 606 407 180 169 962 372 6 -103 356 308 618 -85 -203 -172 -70 349 357 141 128 175
|
||||
|
||||
MSD: обрабатываем диапазон [0; 149], байт №3.
|
||||
-219 -13 -112 -213 -153 -116 -243 -154 -59 -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 59 183 240 189 407 532 731 237 30 791 977 585 801 945 481 822 640 253 279 830 147 680 373 533 652 506 664 535 389 843 457 802 322 426 204 833 515 555 54 899 83 288 222 549 804 471 612 578 19 840 695 876 691 398 551 323 587 225 132 486 684 609 895 50 72 940 568 760 815 50 743 389 823 145 991 432 678 912 886 333 359 168 605 722 467 166 310 649 118 148 221 643 601 56 867 467 988 917 716 535 431 549 665 636 388 606 407 180 169 962 372 6 356 308 618 349 357 141 128 175
|
||||
|
||||
MSD: обрабатываем диапазон [0; 29], байт №2.
|
||||
-219 -13 -112 -213 -153 -116 -243 -154 -59 -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 59 183 240 189 407 532 731 237 30 791 977 585 801 945 481 822 640 253 279 830 147 680 373 533 652 506 664 535 389 843 457 802 322 426 204 833 515 555 54 899 83 288 222 549 804 471 612 578 19 840 695 876 691 398 551 323 587 225 132 486 684 609 895 50 72 940 568 760 815 50 743 389 823 145 991 432 678 912 886 333 359 168 605 722 467 166 310 649 118 148 221 643 601 56 867 467 988 917 716 535 431 549 665 636 388 606 407 180 169 962 372 6 356 308 618 349 357 141 128 175
|
||||
|
||||
MSD: обрабатываем диапазон [30; 149], байт №2.
|
||||
-219 -13 -112 -213 -153 -116 -243 -154 -59 -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 59 183 240 189 407 532 731 237 30 791 977 585 801 945 481 822 640 253 279 830 147 680 373 533 652 506 664 535 389 843 457 802 322 426 204 833 515 555 54 899 83 288 222 549 804 471 612 578 19 840 695 876 691 398 551 323 587 225 132 486 684 609 895 50 72 940 568 760 815 50 743 389 823 145 991 432 678 912 886 333 359 168 605 722 467 166 310 649 118 148 221 643 601 56 867 467 988 917 716 535 431 549 665 636 388 606 407 180 169 962 372 6 356 308 618 349 357 141 128 175
|
||||
|
||||
MSD: обрабатываем диапазон [30; 149], байт №1.
|
||||
-219 -13 -112 -213 -153 -116 -243 -154 -59 -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 59 183 240 189 237 30 253 147 204 54 83 222 19 225 132 50 72 50 145 168 166 118 148 221 56 180 169 6 141 128 175 407 481 279 373 506 389 457 322 426 288 471 398 323 486 389 432 333 359 467 310 467 431 388 407 372 356 308 349 357 532 731 585 640 680 533 652 664 535 515 555 549 612 578 695 691 551 587 684 609 568 760 743 678 605 722 649 643 601 716 535 549 665 636 606 618 791 977 801 945 822 830 843 802 833 899 804 840 876 895 940 815 823 991 912 886 867 988 917 962
|
||||
|
||||
MSD: обрабатываем диапазон [30; 60], байт №0.
|
||||
-219 -13 -112 -213 -153 -116 -243 -154 -59 -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 407 481 279 373 506 389 457 322 426 288 471 398 323 486 389 432 333 359 467 310 467 431 388 407 372 356 308 349 357 532 731 585 640 680 533 652 664 535 515 555 549 612 578 695 691 551 587 684 609 568 760 743 678 605 722 649 643 601 716 535 549 665 636 606 618 791 977 801 945 822 830 843 802 833 899 804 840 876 895 940 815 823 991 912 886 867 988 917 962
|
||||
|
||||
MSD: обрабатываем диапазон [61; 89], байт №0.
|
||||
-219 -13 -112 -213 -153 -116 -243 -154 -59 -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 532 731 585 640 680 533 652 664 535 515 555 549 612 578 695 691 551 587 684 609 568 760 743 678 605 722 649 643 601 716 535 549 665 636 606 618 791 977 801 945 822 830 843 802 833 899 804 840 876 895 940 815 823 991 912 886 867 988 917 962
|
||||
|
||||
MSD: обрабатываем диапазон [90; 125], байт №0.
|
||||
-219 -13 -112 -213 -153 -116 -243 -154 -59 -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 977 801 945 822 830 843 802 833 899 804 840 876 895 940 815 823 991 912 886 867 988 917 962
|
||||
|
||||
MSD: обрабатываем диапазон [126; 149], байт №0.
|
||||
-219 -13 -112 -213 -153 -116 -243 -154 -59 -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 833 840 843 867 876 886 895 899 912 917 940 945 962 977 988 991
|
||||
|
||||
Дополнительный этап: разворот массива для режима по убыванию.
|
||||
Меняем местами -219 и 991.
|
||||
[991] -13 -112 -213 -153 -116 -243 -154 -59 -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 833 840 843 867 876 886 895 899 912 917 940 945 962 977 988 [-219]
|
||||
Меняем местами -13 и 988.
|
||||
991 [988] -112 -213 -153 -116 -243 -154 -59 -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 833 840 843 867 876 886 895 899 912 917 940 945 962 977 [-13] -219
|
||||
Меняем местами -112 и 977.
|
||||
991 988 [977] -213 -153 -116 -243 -154 -59 -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 833 840 843 867 876 886 895 899 912 917 940 945 962 [-112] -13 -219
|
||||
Меняем местами -213 и 962.
|
||||
991 988 977 [962] -153 -116 -243 -154 -59 -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 833 840 843 867 876 886 895 899 912 917 940 945 [-213] -112 -13 -219
|
||||
Меняем местами -153 и 945.
|
||||
991 988 977 962 [945] -116 -243 -154 -59 -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 833 840 843 867 876 886 895 899 912 917 940 [-153] -213 -112 -13 -219
|
||||
Меняем местами -116 и 940.
|
||||
991 988 977 962 945 [940] -243 -154 -59 -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 833 840 843 867 876 886 895 899 912 917 [-116] -153 -213 -112 -13 -219
|
||||
Меняем местами -243 и 917.
|
||||
991 988 977 962 945 940 [917] -154 -59 -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 833 840 843 867 876 886 895 899 912 [-243] -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -154 и 912.
|
||||
991 988 977 962 945 940 917 [912] -59 -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 833 840 843 867 876 886 895 899 [-154] -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -59 и 899.
|
||||
991 988 977 962 945 940 917 912 [899] -42 -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 833 840 843 867 876 886 895 [-59] -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -42 и 895.
|
||||
991 988 977 962 945 940 917 912 899 [895] -110 -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 833 840 843 867 876 886 [-42] -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -110 и 886.
|
||||
991 988 977 962 945 940 917 912 899 895 [886] -106 -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 833 840 843 867 876 [-110] -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -106 и 876.
|
||||
991 988 977 962 945 940 917 912 899 895 886 [876] -249 -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 833 840 843 867 [-106] -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -249 и 867.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 [867] -107 -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 833 840 843 [-249] -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -107 и 843.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 [843] -214 -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 833 840 [-107] -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -214 и 840.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 [840] -87 -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 833 [-214] -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -87 и 833.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 [833] -167 -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 830 [-87] -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -167 и 830.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 [830] -42 -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 823 [-167] -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -42 и 823.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 [823] -133 -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 822 [-42] -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -133 и 822.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 [822] -222 -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 815 [-133] -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -222 и 815.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 [815] -88 -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 804 [-222] -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -88 и 804.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 [804] -56 -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 802 [-88] -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -56 и 802.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 [802] -220 -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 801 [-56] -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -220 и 801.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 [801] -146 -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 791 [-220] -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -146 и 791.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 [791] -47 -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 760 [-146] -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -47 и 760.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 [760] -103 -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 743 [-47] -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -103 и 743.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 [743] -85 -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 731 [-103] -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -85 и 731.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 [731] -203 -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 722 [-85] -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -203 и 722.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 [722] -172 -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 716 [-203] -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -172 и 716.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 [716] -70 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 695 [-172] -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами -70 и 695.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 [695] 6 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 691 [-70] -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 6 и 691.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 [691] 19 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 684 [6] -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 19 и 684.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 [684] 30 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 680 [19] 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 30 и 680.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 [680] 50 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 678 [30] 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 50 и 678.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 [678] 50 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 665 [50] 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 50 и 665.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 [665] 54 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 664 [50] 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 54 и 664.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 [664] 56 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 652 [54] 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 56 и 652.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 [652] 59 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 649 [56] 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 59 и 649.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 [649] 72 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 643 [59] 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 72 и 643.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 [643] 83 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 640 [72] 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 83 и 640.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 [640] 118 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 636 [83] 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 118 и 636.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 [636] 128 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 618 [118] 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 128 и 618.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 [618] 132 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 612 [128] 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 132 и 612.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 [612] 141 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 609 [132] 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 141 и 609.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 [609] 145 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 606 [141] 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 145 и 606.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 [606] 147 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 605 [145] 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 147 и 605.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 [605] 148 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 601 [147] 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 148 и 601.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 [601] 166 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 587 [148] 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 166 и 587.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 [587] 168 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 585 [166] 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 168 и 585.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 [585] 169 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 578 [168] 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 169 и 578.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 [578] 175 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 568 [169] 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 175 и 568.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 [568] 180 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 555 [175] 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 180 и 555.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 [555] 183 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 551 [180] 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 183 и 551.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 [551] 189 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 549 [183] 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 189 и 549.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 [549] 204 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 549 [189] 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 204 и 549.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 [549] 221 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 535 [204] 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 221 и 535.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 [535] 222 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 535 [221] 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 222 и 535.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 [535] 225 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 533 [222] 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 225 и 533.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 [533] 237 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 532 [225] 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 237 и 532.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 [532] 240 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 515 [237] 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 240 и 515.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 [515] 253 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 506 [240] 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 253 и 506.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 [506] 279 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 486 [253] 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 279 и 486.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 506 [486] 288 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 481 [279] 253 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 288 и 481.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 506 486 [481] 308 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 471 [288] 279 253 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 308 и 471.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 506 486 481 [471] 310 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 467 [308] 288 279 253 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 310 и 467.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 506 486 481 471 [467] 322 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 467 [310] 308 288 279 253 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 322 и 467.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 506 486 481 471 467 [467] 323 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 457 [322] 310 308 288 279 253 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 323 и 457.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 506 486 481 471 467 467 [457] 333 349 356 357 359 372 373 388 389 389 398 407 407 426 431 432 [323] 322 310 308 288 279 253 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 333 и 432.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 506 486 481 471 467 467 457 [432] 349 356 357 359 372 373 388 389 389 398 407 407 426 431 [333] 323 322 310 308 288 279 253 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 349 и 431.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 506 486 481 471 467 467 457 432 [431] 356 357 359 372 373 388 389 389 398 407 407 426 [349] 333 323 322 310 308 288 279 253 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 356 и 426.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 506 486 481 471 467 467 457 432 431 [426] 357 359 372 373 388 389 389 398 407 407 [356] 349 333 323 322 310 308 288 279 253 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 357 и 407.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 506 486 481 471 467 467 457 432 431 426 [407] 359 372 373 388 389 389 398 407 [357] 356 349 333 323 322 310 308 288 279 253 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 359 и 407.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 506 486 481 471 467 467 457 432 431 426 407 [407] 372 373 388 389 389 398 [359] 357 356 349 333 323 322 310 308 288 279 253 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 372 и 398.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 506 486 481 471 467 467 457 432 431 426 407 407 [398] 373 388 389 389 [372] 359 357 356 349 333 323 322 310 308 288 279 253 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 373 и 389.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 506 486 481 471 467 467 457 432 431 426 407 407 398 [389] 388 389 [373] 372 359 357 356 349 333 323 322 310 308 288 279 253 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
Меняем местами 388 и 389.
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 506 486 481 471 467 467 457 432 431 426 407 407 398 389 [389] [388] 373 372 359 357 356 349 333 323 322 310 308 288 279 253 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 506 486 481 471 467 467 457 432 431 426 407 407 398 389 389 388 373 372 359 357 356 349 333 323 322 310 308 288 279 253 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
|
||||
Финальный результат:
|
||||
991 988 977 962 945 940 917 912 899 895 886 876 867 843 840 833 830 823 822 815 804 802 801 791 760 743 731 722 716 695 691 684 680 678 665 664 652 649 643 640 636 618 612 609 606 605 601 587 585 578 568 555 551 549 549 535 535 533 532 515 506 486 481 471 467 467 457 432 431 426 407 407 398 389 389 388 373 372 359 357 356 349 333 323 322 310 308 288 279 253 240 237 225 222 221 204 189 183 180 175 169 168 166 148 147 145 141 132 128 118 83 72 59 56 54 50 50 30 19 6 -70 -172 -203 -85 -103 -47 -146 -220 -56 -88 -222 -133 -42 -167 -87 -214 -107 -249 -106 -110 -42 -59 -154 -243 -116 -153 -213 -112 -13 -219
|
||||
|
||||
Reference in New Issue
Block a user