Last active
March 23, 2017 05:07
-
-
Save taylorsmithgg/b98ca243e25b4748cf27f478da710139 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
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