Skip to content

Instantly share code, notes, and snippets.

Created October 4, 2013 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/6828763 to your computer and use it in GitHub Desktop.
Save anonymous/6828763 to your computer and use it in GitHub Desktop.
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