Ни одна из перегрузок метода QuickSorting не принимает 1 аргументов - C#
Формулировка задачи:
прошу помочь, не могу понять как исправить ошибку.
public Form1()
{
InitializeComponent();
txtWriteNum.Focus();
}
//Сортировка пузырьком
private int[] BubbleSort(int[] mas)
{
var stopwatch = System.Diagnostics.Stopwatch.StartNew();
int temp;
for (int i = 0; i < mas.Length; i++)
{
for (int j = i + 1; j < mas.Length; j++)
{
if (mas[i] > mas[j])
{
temp = mas[i];
mas[i] = mas[j];
mas[j] = temp;
}
}
}
stopwatch.Stop();
txtReadArray.Text += Environment.NewLine + "Время выполнения алгоритма: " + stopwatch.Elapsed;
return mas;
}
//Быстрая сортировка
private int[] QuickSorting(int[] arr, long first, long last)
{
int p = arr[(last - first) / 2 + first];
int temp;
long i = first, j = last;
while (i <= j)
{
while (arr[i] < p) i++;
while (arr[j] > p) j--;
if (i <= j)
{
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
i++; j--;
}
}
if (j > first)
QuickSorting(arr, first, j);
if (i < last)
QuickSorting(arr, i, last);
return arr;
}
private void buttSort_Click(object sender, EventArgs e)
{
try
{
int N = Convert.ToInt32(txtWriteNum.Text);
int[] mas = new int[N];
//заполняем массив случайными числами
Random rd = new Random();
for (int i = 0; i < mas.Length; i++)
{
mas[i] = rd.Next(1, 101);
}
txtReadArray.Text += "Массив перед сортировкой: ";
foreach (int x in mas)
{
txtReadArray.Text += x + " ";
}
//вывод сортировки пузырьком
txtReadArray.Text += Environment.NewLine + Environment.NewLine + "Сортировка пузырьком";
BubbleSort(mas);
txtReadArray.Text += Environment.NewLine + "Массив отсортирован: ";
for (int i = 0; i < mas.Length; i++)
{
txtReadArray.Text += mas[i] + " ";
}
txtReadArray.Text += Environment.NewLine + Environment.NewLine + "Быстрая сортировка";
//вывод быстрой сортировки
var stopwatch1 = System.Diagnostics.Stopwatch.StartNew();
QuickSorting(mas);
stopwatch1.Stop();
txtReadArray.Text += Environment.NewLine + "Время выполнения алгоритма: " + stopwatch1.Elapsed;
txtReadArray.Text += Environment.NewLine + "Массив отсортирован: ";
foreach (int x in mas)
{
txtReadArray.Text += x + " ";
}
}
catch
{
MessageBox.Show("Введены не корректные данные", "Ошибка!");
}
}
private void buttClear_Click(object sender, EventArgs e)
{
txtWriteNum.Text = "";
txtReadArray.Text = "";
}
private void buttAbout_Click(object sender, EventArgs e)
{
AboutBox1 abtbtn = new AboutBox1();
abtbtn.Show();
}
private void buttClouse_Click(object sender, EventArgs e)
{
DialogResult status = MessageBox.Show("Вы действительно хотите выйти?", "Выход", MessageBoxButtons.YesNo);
if (status == DialogResult.Yes)
this.Close();
}
}
}Решение задачи: «Ни одна из перегрузок метода QuickSorting не принимает 1 аргументов»
textual
Листинг программы
QuickSorting(mas);