Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
image: Visual Studio 2019

build_script:
- For /R %%I in (*.sln) do dotnet test %%I

test: off
25 changes: 25 additions & 0 deletions hw1Sort/hw1Sort.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31005.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "hw1Sort", "hw1Sort\hw1Sort.csproj", "{B0687189-596B-44A1-BEDF-E6832C5A3681}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B0687189-596B-44A1-BEDF-E6832C5A3681}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0687189-596B-44A1-BEDF-E6832C5A3681}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0687189-596B-44A1-BEDF-E6832C5A3681}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0687189-596B-44A1-BEDF-E6832C5A3681}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {041E2F7B-8765-486E-AD50-75F5DE00B0A1}
EndGlobalSection
EndGlobal
65 changes: 65 additions & 0 deletions hw1Sort/hw1Sort/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;

namespace hw1Sort
{
class Program
{
static void Sort(int[] array)
{
for (int i = 0; i < array.Length - 1; i++)
{
for (int j = i + 1; j < array.Length; j++)
{
if (array[i] > array[j])
{
int numberSwap;
numberSwap = array[i];
Comment on lines +15 to +16
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int numberSwap = array[i];

array[i] = array[j];
array[j] = numberSwap;
}
}
}
}

static bool Test()
{
int[] array = { 9, 3, 2, 5, 7, 8 };
Sort(array);
for (int i = 0; i < array.Length - 1; i++)
{
if (array[i] > array[i + 1])
{
return false;
}
}
return true;
}

static void Main(string[] args)
{
if (!Test())
{
Console.WriteLine("Тест не пройден!");
return;
}
Console.WriteLine("Тест пройден!");
Console.WriteLine("Введите числа для сортировки: ");
string str = Console.ReadLine();
string[] numbers = str.Split(' ');
int[] array = new int[numbers.Length];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var, мы знаем тип из правой части

int count = 0;
foreach (var s in numbers)
{
array[count] = int.Parse(s);
count++;
}
Sort(array);
Console.WriteLine("Отсортированный массив: ");
for (int i = 0; i < array.Length; i++)
{
Console.Write(array[i]);
Console.Write(" ");
}
}
}
}
8 changes: 8 additions & 0 deletions hw1Sort/hw1Sort/hw1Sort.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

</Project>