1. On Saturday September 3RD, 2016 this community will be shutdown permanently.

    The time has come to close this community. I no longer have any interest in Visual Studio programming and my efforts to find someone to take over the community has failed.

    If anyone is interested in acquiring the database contact me and I will make it available for you.

Problem with Quick sort c#

Discussion in 'Visual C# .Net' started by DN Admin, May 5, 2012.

  1. DN Admin

    DN Admin Administrator
    Staff Member

    United States
    Aug 7, 2010
    Likes Received:
    Joliet, IL U.S.A.
    Hi, i have tried to do a quick sort in c#. I have no errors in the code, but in my program i get errors.
    My code looks like this in the program: And it complains at "array" which doesn't exist in the currrent context.
    static void Main(string[] args)<br/>
    int[] Array = RandomIntArray(7);<br/>
    Sort sorterar = new Sort();<br/>
    for (int a = 0; a < array.Length; a++)<br/>
    The Sort class looks like this:
    public void QuickSort(int[] array, int left, int right)<br/>
    if( array == null ) <br/>
    return; <br/>
    int i = left; <br/>
    int j = right; <br/>
    int pivot = array[( left + right ) / 2]; <br/>
    while( i <= j ) <br/>
    { <br/>
    while( array < pivot ) <br/>
    i++; <br/>
    while( array[j] > pivot ) <br/>
    j--; <br/>
    if( i <= j ) <br/>
    { <br/>
    int tmp = array; <br/>
    array[i++] = array[j]; <br/>
    array[j--] = tmp; <br/>
    } <br/>
    } <br/>
    if( j > left ) <br/>
    { <br/>
    QuickSort( array, left, j ); <br/>
    } <br/>
    if( i < right ) <br/>
    { <br/>
    QuickSort( array, i, right ); <br/>
    } <br/>

    I hope someone could knew whats the problem is!<br/>

    View the full article

Share This Page