编程题格式问题的求助!!!
刚才做一个公司的笔试题,懵逼了!要求实现快速排序,输入数组,输出数组,这个题没有类、函数的提示,空白开始编写。我按牛客的格式写的类,本地运行没问题,提交报错。自测提示没有main函数!
以下是我的代码:请问到底怎么编写,难道是控制台输入数组?
public class Main { public static int[] sort(int[] arr) { if (arr.length == 0 || arr.length == 1) return arr; QuickSort(arr, 0, arr.length - 1); return arr; } private static void QuickSort(int[] arr, int low, int high) { int temp = low; int temp1 = high; if (temp >= temp1) return; while (low < high) { while (arr[high] >= arr[temp] && low < high) high--; while (arr[low] <= arr[temp] && low < high) low++; if (low < high) { int mid = arr[high]; arr[high] = arr[low]; arr[low] = mid; } } if (low == high) { int mid = arr[temp]; arr[temp] = arr[high]; arr[high] = mid; } QuickSort(arr, temp, high - 1); QuickSort(arr, high + 1, temp1); } }