import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.util.Scanner;
public class Lab3 {
public static void main(String[] args) throws IOException {
System.out.print("Name of file with array: ");
Scanner readIn = new Scanner(System.in);
String input = readIn.nextLine();
}
public static void testScan1(String filename) //"Return type is missing for method"
{
File file = new File(filename);
Scanner scan;
try {
int[] array = new int[5];
scan = new Scanner(file);
} catch (java.io.FileNotFoundException e) {
System.out.println("couldn't open. file not found ");
return;
}
while (scan.hasNext()) //"underlies "hasNext" "Method hasNext() is undefined"
{
for (int i = 0; i <= file.length(); ++i) {
// **array**[i]=scan.next(); //"Array cannot be Resolved"
}
}
}
int partition(int[] arr, int left, int right) {
int i = left;
int j = right;
int tmp;
int pivot = arr[(left + right) / 2];
while (i <= j) {
while (arr[i] < pivot)
i++;
while (arr[j] > pivot)
j--;
if (i <= j) {
tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
i++;
j--;
}
}
return i;
}
void quickSort(int[] arr, int left, int right) {
int index = partition(arr, left, right);
if (left < (index - 1)) {
;
}
quickSort(arr, left, index - 1);
if (index < right) {
quickSort(arr, index, right);
}
}
}
|