First commit in 8 years! Just cleanup
This commit is contained in:
parent
e39fa42940
commit
e14e47209b
3 changed files with 74 additions and 102 deletions
|
@ -1,17 +0,0 @@
|
||||||
<?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>
|
|
|
@ -1,11 +0,0 @@
|
||||||
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
|
|
|
@ -1,75 +1,75 @@
|
||||||
package bz.bronze.selectionsort;
|
package com.okseby.selectionsort;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @author bronze
|
* @author okseby
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class aa {
|
public class aa {
|
||||||
static Random rng = new Random();
|
static Random rng = new Random();
|
||||||
|
|
||||||
static int length = 11;
|
static int length = 11;
|
||||||
static int[] numbers = new int[length];
|
static int[] numbers = new int[length];
|
||||||
static int t;
|
static int t;
|
||||||
static int total;
|
static int total;
|
||||||
static int x;
|
static int x;
|
||||||
static int mean;
|
static int mean;
|
||||||
static int median;
|
static int median;
|
||||||
|
|
||||||
public static void getMedian()
|
public static void getMedian()
|
||||||
{
|
{
|
||||||
x = length / 2;
|
x = length / 2;
|
||||||
median = numbers[x];
|
median = numbers[x];
|
||||||
|
|
||||||
System.out.println("Median: " + median);
|
System.out.println("Median: " + median);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getMean()
|
public static void getMean()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numbers.length; i++)
|
for (int i = 0; i < numbers.length; i++)
|
||||||
{
|
{
|
||||||
total += numbers[i];
|
total += numbers[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
mean = total / length;
|
mean = total / length;
|
||||||
System.out.println("Mean: " + mean);
|
System.out.println("Mean: " + mean);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sort()
|
public static void sort()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < numbers.length; i++)
|
for (int i = 0; i < numbers.length; i++)
|
||||||
{
|
{
|
||||||
for (int j = i; j < numbers.length; j++)
|
for (int j = i; j < numbers.length; j++)
|
||||||
{
|
{
|
||||||
if(numbers[j] < numbers[i])
|
if(numbers[j] < numbers[i])
|
||||||
{
|
{
|
||||||
t = numbers[i];
|
t = numbers[i];
|
||||||
numbers[i] = numbers[j];
|
numbers[i] = numbers[j];
|
||||||
numbers[j] = t;
|
numbers[j] = t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Postsort: " + Arrays.toString(numbers));
|
System.out.println("Postsort: " + Arrays.toString(numbers));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void generate(int length)
|
public static void generate(int length)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < length; i++)
|
for(int i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
numbers[i] = rng.nextInt(99);
|
numbers[i] = rng.nextInt(99);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Presort: " + Arrays.toString(numbers));
|
System.out.println("Presort: " + Arrays.toString(numbers));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
generate(length);
|
generate(length);
|
||||||
sort();
|
sort();
|
||||||
getMean();
|
getMean();
|
||||||
getMedian();
|
getMedian();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue