GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — sorting/sorting/src/dip107/Main.java at main · 4math/sorting Expand file tree/ Copy pathMain.javaMore file actions 93 lines (76 loc) · 2.92 KB / Copy pathMain.javaFile metadata and controls93 lines (76 loc) · 2.92 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 package dip107; import java.util.Scanner; public class Main { public static void main(String[] args) { System.out.println("Name"); System.out.println("Name"); System.out.println("Name"); boolean fFullTest = false; boolean fOutputAvg = false; for (String arg : args) { if (arg.compareTo("-fOutputAvg") == 0) { fOutputAvg = true; } if (arg.compareTo("-fFullTest") == 0) { fFullTest = true; } } SortingAlgorithm[] algorithms = {new QuickSort(), new CountingSort(), new ShakerSort()}; TestingFramework tf = new TestingFramework(algorithms, 100); if (fFullTest) { test(tf, 1000); tf.writeTimeResultsToCSV("TimeResults.csv"); } else if (fOutputAvg) { test(tf, 1000); tf.writeAvgResultsToCSV("AvgResults.csv"); } else { try { Scanner scanner = new Scanner(System.in); System.out.print("Enter array element count: "); int count = scanner.nextInt(); int[] array = new int[count]; System.out.println("items: "); for (int i = 0; i < count; i++) { array[i] = scanner.nextInt(); } System.out.println("Choose the sorting method: "); System.out.println("1: Quicksort method"); System.out.println("2: Shaker sort method"); System.out.println("3: Counting sort method"); int choice = scanner.nextInt(); while (choice < 1 || choice > 3) { System.out.println("Choose the sorting method: "); choice = scanner.nextInt(); } switch (choice) { case 1: QuickSort.sort(array, 0, array.length - 1, 1); break; case 2: ShakerSort.sort(array, 0, array.length - 1, 1); break; case 3: CountingSort.sortModified(array, 1); break; default: return; } System.out.println("result: "); for (int i = 0; i < count; i++) { System.out.printf("%d ", array[i]); } } catch (Exception e) { System.out.println("input-output error"); } } } private static void test(TestingFramework tf, int border) { for (int i = 0; i < 3; i++) { long start = System.nanoTime(); tf.test(border); long end = System.nanoTime(); System.out.println("Test " + i + " has finished in " + (end - start) / 10e6); } tf.printTimeResults(); } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |