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;
|
||||
|
||||
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();
|
||||
}
|
||||
package com.okseby.selectionsort;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Arrays;
|
||||
|
||||
/*
|
||||
* @author okseby
|
||||
*/
|
||||
|
||||
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