Сортировка по возрастанию - C# (178007)
Формулировка задачи:
Что не правильно делаю?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Qsort
{
class Program
{
static void Main(string[] args)
{
QuickSort_1();
Console.ReadKey();
}
public static void QuickSort_1()
{
int[] ee = new[] { 33, 14, 11, 22 };
int temp;
for (int i = 0; i == ee.Length-1; i++)
{
for (int j = i+1; j == ee.Length; j++)
{
if (ee[i]>ee[j])
{
temp = ee[j];
ee[j] = ee[i];
ee[i] = temp;
}
}
}
for (int i = 0; i == ee.Length; i++)
{
Console.WriteLine(ee[i]);
}
}
}
}Решение задачи: «Сортировка по возрастанию»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication5
{
class Program
{
public static void swap(ref int a, ref int b)
{
int c = a;
a = b;
b = c;
}
public static void sortirovka()
{
Random rnd = new Random();
rnd.Next();
int[] array = new int[3];
for (int i = 0; i < 3; i++)
{
array[i] = rnd.Next(0,100);
}
for (int i = 0; i < 3; i++)
{
Console.WriteLine(array[i]);
}
for (int i = 0; i < 2; i++)
{
for (int j = i+1; j < 3; j++)
{
if ( array[i]>array[j])
{
swap(ref array[i],ref array[j]);
}
}
}
Console.WriteLine();
for (int i = 0; i < 3; i++)
{
Console.WriteLine(array[i]);
}
return;
}
static void Main(string[] args)
{
sortirovka();
Console.ReadKey();
}
}
}