#cannot find symbol of printArray(numbers); in my code

1 messages · Page 1 of 1 (latest)

thorn sierra
#

import java.util.Random;
public class Main
{
public static void main(String[] args) {
Random rand = new Random();
int[] numbers = {80, 72, 3, 83, 2, 11, 96, 13, 41, 49, 99, 97, 56, 31, 12, 64, 37, 42, 2, 11, 9, 96, 4, 91, 53, 82, 8, 8, 8, 99, 17, 34, 74, 1, 62, 4, 18, 41, 79, 92, 9, 47, 84, 45, 13, 12, 12, 81, 75, 86, 76, 26, 30, 3, 88, 77, 17, 36, 98, 93, 95, 22, 86, 27, 42, 0, 37, 26, 22, 56, 86, 99, 16, 63, 59, 65, 73, 43, 39, 25, 46, 1, 56, 65, 16, 55, 96, 21, 3, 58, 85, 88, 3, 4, 44, 84, 32, 22, 83, 54};

    for(int i = 0; i < numbers.length; i++) {
        numbers[i] = rand.nextInt(100);
    }
    
    
    System.out.println("before");
    printArray(numbers);
    quicksort(numbers, 0, numbers.length - 1);
    System.out.println("/nAfter:");
    printArray(numbers);
}
private static void quicksort(int[] array, int lowIndex, int highIndex) {
    if(lowIndex >= highIndex) {
        return;
    }
    int pivot = array[highIndex];
    
    int leftPointer = lowIndex;
    int rightPointer = highIndex;
    
    while(leftPointer < rightPointer) {
        
        while (array[leftPointer] <= pivot && leftPointer < rightPointer) {
            leftPointer++;
        }
        
        while (array[rightPointer] >= pivot && leftPointer < rightPointer) {
            rightPointer--;
        }
        swap(array, leftPointer, rightPointer);
    }
    swap(array, leftPointer, highIndex);
    quicksort(array, lowIndex, leftPointer -1);
    quicksort(array, leftPointer + 1, highIndex);
}

private static void swap(int[] array, int index1, int index2) {
    int temp = array[index1];
    array[index1] = array[index2];
    array[index2] = temp;
}

}

dense barnBOT
#

This post has been reserved for your question.

Hey @thorn sierra! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

dense barnBOT
#

💤 Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.