commit 070edd6013a4dc83b99c8553aaf42f57448f5759 Author: Sebastian Cabrera Date: Sat Apr 2 20:31:07 2016 -0400 Initial Commit diff --git a/Selection Sort/.classpath b/Selection Sort/.classpath new file mode 100644 index 0000000..63b7e89 --- /dev/null +++ b/Selection Sort/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/Selection Sort/.gitignore b/Selection Sort/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/Selection Sort/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/Selection Sort/.project b/Selection Sort/.project new file mode 100644 index 0000000..2570077 --- /dev/null +++ b/Selection Sort/.project @@ -0,0 +1,17 @@ + + + Selection Sort + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Selection Sort/.settings/org.eclipse.jdt.core.prefs b/Selection Sort/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/Selection Sort/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Selection Sort/src/bz/bronze/selectionsort/aa.java b/Selection Sort/src/bz/bronze/selectionsort/aa.java new file mode 100644 index 0000000..a279a20 --- /dev/null +++ b/Selection Sort/src/bz/bronze/selectionsort/aa.java @@ -0,0 +1,75 @@ +package bz.bronze.selectionsort; + +import java.util.Random; +import java.util.Arrays; + +/* + * @author bronze + */ + +public class aa { + static Random rng = new Random(); + + static int length = 11; + static int[] numbers = new int[length]; + static int t; + static int total; + static int x; + static int mean; + static int median; + + public static void getMedian() + { + x = length / 2; + median = numbers[x]; + + System.out.println("Median: " + median); + } + + public static void getMean() + { + for (int i = 0; i < numbers.length; i++) + { + total += numbers[i]; + } + + mean = total / length; + System.out.println("Mean: " + mean); + } + + public static void sort() + { + for (int i = 0; i < numbers.length; i++) + { + for (int j = i; j < numbers.length; j++) + { + if(numbers[j] < numbers[i]) + { + t = numbers[i]; + numbers[i] = numbers[j]; + numbers[j] = t; + } + } + } + + System.out.println("Postsort: " + Arrays.toString(numbers)); + } + + public static void generate(int length) + { + for(int i = 0; i < length; i++) + { + numbers[i] = rng.nextInt(99); + } + + System.out.println("Presort: " + Arrays.toString(numbers)); + } + + public static void main(String[] args) + { + generate(length); + sort(); + getMean(); + getMedian(); + } +} \ No newline at end of file