Created
October 4, 2013 16:31
-
-
Save anonymous/6828763 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
package com.company; | |
import java.util.Random; | |
public class Main { | |
public static int minindx(int u[],int y){ | |
int minIndex = y; | |
for(int i=y;i<u.length;i++){ | |
if(u[minIndex] > u[i]){ | |
minIndex = i; | |
} | |
} | |
return minIndex; | |
} | |
public static void sort(int x[]){ | |
for(int k=0;k<x.length;k++){ | |
int minI = minindx(x, k); | |
int l = x[k]; | |
x[k] = x[minI]; | |
x[minI] = l; | |
} | |
} | |
public static void main(String[] args) { | |
int x[] = new int [50]; | |
Random r = new Random (); | |
for(int i = 0; i < x.length; i++){ | |
int n = r.nextInt(300)-150; | |
x[i] = n; | |
} | |
sort(x); | |
for(int i=0;i<x.length;i++){ | |
System.out.println( x[i] ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment