generated from ISUCT/Tprogramming_42_2020
-
Notifications
You must be signed in to change notification settings - Fork 43
BubbleSort Task #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Pigolitsyn
wants to merge
17
commits into
ISUCT:Semen_Pigolitsyn
Choose a base branch
from
Pigolitsyn:Semen_Pigolitsyn
base: Semen_Pigolitsyn
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
BubbleSort Task #32
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5b9049c
Update README.md
Pigolitsyn 4ecde77
Update workflow
Pigolitsyn c0a3f73
Merge branch 'ISUCT:Semen_Pigolitsyn' into Semen_Pigolitsyn
Pigolitsyn 1a8f3da
Merge branch 'ISUCT:Semen_Pigolitsyn' into Semen_Pigolitsyn
Pigolitsyn 75cef68
Add own BubbleSort's realization
Pigolitsyn c5a4be4
Update Program.cs to work with BubbleSort
Pigolitsyn f8fe043
Fix code by stylecop and update BubbleSort.cs to test format
Pigolitsyn 2822939
Fix test to check last string on output
Pigolitsyn 2d78f13
Add PairSort and tests
Pigolitsyn a7ab01d
fix pair sort test
Pigolitsyn 767998d
delete useless using
Pigolitsyn 269812b
Fix BubbleSortTest finally, i hope
Pigolitsyn a0db6c4
merge sort step 1 + add input handler
Pigolitsyn b66d1c9
fix bubble sort
Pigolitsyn 8f1d77e
try to fix mergesort without results
Pigolitsyn a2dce06
add countDiff
Pigolitsyn d5d0e16
delete useless var
Pigolitsyn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,31 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>netcoreapp2.1</TargetFramework> | ||
| <TreatWarningsAsErrors>True</TreatWarningsAsErrors> | ||
| <NoWarn>1573,1591,1701;1702;1705</NoWarn> | ||
| <IsPackable>false</IsPackable> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <TargetFramework>net6.0</TargetFramework> | ||
| <TreatWarningsAsErrors>True</TreatWarningsAsErrors> | ||
| <NoWarn>1573,1591,1701;1702;1705</NoWarn> | ||
| <IsPackable>false</IsPackable> | ||
| <LangVersion>10</LangVersion> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> | ||
| <PackageReference Include="xunit" Version="2.4.0" /> | ||
| <PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" /> | ||
| <PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="all" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> | ||
| <PackageReference Include="xunit" Version="2.4.0" /> | ||
| <PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" /> | ||
| <PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="all" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\CourseApp\CourseApp.csproj" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ProjectReference Include="..\CourseApp\CourseApp.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <CodeAnalysisRuleSet>../_stylecop/stylecop.ruleset</CodeAnalysisRuleSet> | ||
| <GenerateFullPaths>true</GenerateFullPaths> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <CodeAnalysisRuleSet>../_stylecop/stylecop.ruleset</CodeAnalysisRuleSet> | ||
| <GenerateFullPaths>true</GenerateFullPaths> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <AdditionalFiles Include="../_stylecop/stylecop.json" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <AdditionalFiles Include="../_stylecop/stylecop.json" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| using Module2; | ||
|
|
||
| namespace CourseApp.Tests.Module2; | ||
|
|
||
| using System; | ||
| using System.IO; | ||
| using Xunit; | ||
|
|
||
| [Collection("Sequential")] | ||
| public class PairSortTest : IDisposable | ||
| { | ||
| private const string Inp1 = @"3 | ||
| 101 80 | ||
| 305 90 | ||
| 200 14"; | ||
|
|
||
| private const string Out1 = @"305 90 | ||
| 101 80 | ||
| 200 14"; | ||
|
|
||
| private const string Inp2 = @"3 | ||
| 20 80 | ||
| 30 90 | ||
| 25 90"; | ||
|
|
||
| private const string Out2 = @"25 90 | ||
| 30 90 | ||
| 20 80"; | ||
|
|
||
| public void Dispose() | ||
| { | ||
| var standardOut = new StreamWriter(Console.OpenStandardOutput()); | ||
| standardOut.AutoFlush = true; | ||
| var standardIn = new StreamReader(Console.OpenStandardInput()); | ||
| Console.SetOut(standardOut); | ||
| Console.SetIn(standardIn); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(Inp1, Out1)] | ||
| [InlineData(Inp2, Out2)] | ||
| public void Test1(string input, string expected) | ||
| { | ||
| var stringWriter = new StringWriter(); | ||
| Console.SetOut(stringWriter); | ||
|
|
||
| var stringReader = new StringReader(input); | ||
| Console.SetIn(stringReader); | ||
|
|
||
| // act | ||
| PairSort.Sort(); | ||
|
|
||
| // assert | ||
| var output = stringWriter.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries); | ||
Pigolitsyn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| var result = string.Join(Environment.NewLine, output); | ||
|
|
||
| Assert.Equal($"{expected}", result); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,24 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>netcoreapp2.1</TargetFramework> | ||
| <TreatWarningsAsErrors>True</TreatWarningsAsErrors> | ||
| <NoWarn>1573,1591,1701;1702;1705;</NoWarn> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net6.0</TargetFramework> | ||
| <TreatWarningsAsErrors>True</TreatWarningsAsErrors> | ||
| <NoWarn>1573,1591,1701;1702;1705;</NoWarn> | ||
| <LangVersion>10</LangVersion> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="all" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="all" /> | ||
| </ItemGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <CodeAnalysisRuleSet>../_stylecop/stylecop.ruleset</CodeAnalysisRuleSet> | ||
| <GenerateFullPaths>true</GenerateFullPaths> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <CodeAnalysisRuleSet>../_stylecop/stylecop.ruleset</CodeAnalysisRuleSet> | ||
| <GenerateFullPaths>true</GenerateFullPaths> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <AdditionalFiles Include="../_stylecop/stylecop.json" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <AdditionalFiles Include="../_stylecop/stylecop.json" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| using System; | ||
|
|
||
| namespace Module2 | ||
| { | ||
| public class PairSort | ||
| { | ||
| public static void Sort() | ||
| { | ||
| int countPair = Convert.ToInt32(Console.ReadLine()); | ||
| int[,] pairs = new int[countPair, 2]; | ||
| for (int i = 0; i < countPair; i++) | ||
| { | ||
| var lol = Console.ReadLine().Split(" "); | ||
| pairs[i, 0] = Convert.ToInt32(lol[0]); | ||
| pairs[i, 1] = Convert.ToInt32(lol[1]); | ||
| } | ||
|
|
||
| for (int i = 0; i < (pairs.Length / 2); ++i) | ||
| { | ||
| for (int j = 0; j < (pairs.Length / 2) - i - 1; ++j) | ||
| { | ||
| if (pairs[j, 1] < pairs[j + 1, 1]) | ||
| { | ||
| (pairs[j, 0], pairs[j + 1, 0]) = (pairs[j + 1, 0], pairs[j, 0]); | ||
| (pairs[j, 1], pairs[j + 1, 1]) = (pairs[j + 1, 1], pairs[j, 1]); | ||
| } | ||
| else if (pairs[j, 1] == pairs[j + 1, 1]) | ||
| { | ||
| if (pairs[j, 0] > pairs[j + 1, 0]) | ||
| { | ||
| (pairs[j, 0], pairs[j + 1, 0]) = (pairs[j + 1, 0], pairs[j, 0]); | ||
| (pairs[j, 1], pairs[j + 1, 1]) = (pairs[j + 1, 1], pairs[j, 1]); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| for (int i = 0; i < pairs.Length / 2; i++) | ||
| { | ||
| Console.WriteLine($"{pairs[i, 0]} {pairs[i, 1]}"); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.