Skip to content

Instantly share code, notes, and snippets.

@taylorsmithgg
Last active March 23, 2017 05:07
Show Gist options
  • Save taylorsmithgg/b98ca243e25b4748cf27f478da710139 to your computer and use it in GitHub Desktop.
Save taylorsmithgg/b98ca243e25b4748cf27f478da710139 to your computer and use it in GitHub Desktop.
import java.lang.reflect.Array;
import java.util.Scanner;
import java.util.Arrays;
class scratch_10{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String[] numbers = scanner.nextLine().split(" ");
String[] result = (String[]) Array.newInstance(String.class, numbers.length + 1);
System.arraycopy(numbers, 0, result, 0, numbers.length);
result[result.length - 1] = Integer.toString((int)(Math.random() * 100));
Arrays.sort(result);
for(String s : result){
System.out.print(s);
System.out.print(" ");
}
}
public static void randomDigits(){
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt();
String[] numbers = new String[num];
int i = 0;
for(String s : numbers) {
s = Integer.toString((int) (Math.random() * 100));
numbers[i] = s;
System.out.print(s);
System.out.print(" ");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment