Answer the question
In order to leave comments, you need to log in
Why is an array needed in the method and what should be done so that when entering data into the array, an exception is not thrown?
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
void Func(int[] numbers,int L, int R)
{
int middle, I, J, F, Z;
I = L; J = R;
middle = (L + R) / 2;
do
{
do
{
F = 0;
if (numbers[I] < numbers[middle]) F = -1;
if (numbers[I] > numbers[middle]) F = 1;
if (F > 0) I = I + 1;
Console.WriteLine(I);
}
while
(F < 0);
do
{
F = 0;
if (numbers[J] < numbers[middle]) F = -1;
if (numbers[J] > numbers[middle]) F = 1;
if (F > 0) J = J + 1;
Console.WriteLine(J);
}
while
(F < 0);
if (I <= J)
{
Z = numbers[I]; numbers[I] = numbers[J]; numbers[J] = Z;
}
}
while
(I <= J);
if (L < J) Func(numbers, L, J);
else if (I < R) Func(numbers, I, R);
}
Func(numbers,15, 10);
}
}
}
Answer the question
In order to leave comments, you need to log in
You saved the code crookedly, apparently. You have func nested in main. This is firstly, and secondly, why - this is after all quick sorting, and yes, in order to sort an array, you need to pass it to it. And inputting data to an array in your code is not currently present.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question