2 changed files with 51 additions and 0 deletions
@ -0,0 +1,43 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace szkola_2._0; |
||||
|
{ |
||||
|
|
||||
|
class Program |
||||
|
{ |
||||
|
|
||||
|
public static void sortowanie(int[] sort;) |
||||
|
{ |
||||
|
int length = sort.length; |
||||
|
do |
||||
|
{ |
||||
|
for(int i=0; i<length-1; i++) |
||||
|
{ |
||||
|
if(sort[i]>sort[i+1]) |
||||
|
Darek7D marked this conversation as resolved
|
|||||
|
{ |
||||
|
int support = sort[i]; |
||||
|
Darek7D marked this conversation as resolved
|
|||||
|
sort[i] = sort[i+1]; |
||||
|
sort[i+1] = support; |
||||
|
} |
||||
|
Darek7D marked this conversation as resolved
|
|||||
|
} |
||||
|
length--; |
||||
|
} |
||||
|
while(length>1); |
||||
|
for(int j = length-1; j >= 0; j--) |
||||
|
Darek7D
commented 5 years ago
Review
Wypisywać wartości o początku a nie od końca. |
|||||
|
{ |
||||
|
Console.Write(sort[j] + ","); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
static void Main(string[] args) |
||||
|
{ |
||||
|
int[] sortowanie = {21, 14, 1, 66, 45}; |
||||
|
|
||||
|
sortowanie(sortowanie[]); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<OutputType>Exe</OutputType> |
||||
|
<TargetFramework>net5.0</TargetFramework> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
</Project> |
||||
Loading…
Reference in new issue
Proponuje zostawić tą linię, a resztę przenieść do funkcji
void sortowanie()i przekazywać do niej tą tablicęsort.