Created
April 24, 2013 15:27
-
-
Save hiroism007/5453002 to your computer and use it in GitHub Desktop.
選択ソート
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Sort { | |
static int[]testNumbers; | |
public static void main(String[] args) { | |
testNumbers = new int[10]; | |
for (int i = 0; i < testNumbers.length; i++) testNumbers[i] = (int) (Math.random() * testNumbers.length + 1); | |
for (int i :testNumbers) System.out.print(i); | |
for (int i = 0; i < testNumbers.length -1; i++){ | |
for (int j = i + 1; j < testNumbers.length; j++){ | |
if (testNumbers[j]< testNumbers[i]){ | |
int t = testNumbers[i]; | |
testNumbers[i] = testNumbers[j]; | |
testNumbers[j] = t; | |
} | |
} | |
} | |
for (int i :testNumbers) System.out.println(i); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment