Initial Commit
This commit is contained in:
commit
070edd6013
5 changed files with 110 additions and 0 deletions
6
Selection Sort/.classpath
Normal file
6
Selection Sort/.classpath
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||||
|
<classpathentry kind="output" path="bin"/>
|
||||||
|
</classpath>
|
1
Selection Sort/.gitignore
vendored
Normal file
1
Selection Sort/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/bin/
|
17
Selection Sort/.project
Normal file
17
Selection Sort/.project
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>Selection Sort</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
11
Selection Sort/.settings/org.eclipse.jdt.core.prefs
Normal file
11
Selection Sort/.settings/org.eclipse.jdt.core.prefs
Normal file
|
@ -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
|
75
Selection Sort/src/bz/bronze/selectionsort/aa.java
Normal file
75
Selection Sort/src/bz/bronze/selectionsort/aa.java
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue