-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumbers.java
More file actions
38 lines (30 loc) · 1001 Bytes
/
Numbers.java
File metadata and controls
38 lines (30 loc) · 1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// ******************************************************
// Numbers.java
//
// Demonstrates selectionSort on an array of integers.
// ******************************************************
import java.util.Scanner;
public class Numbers
{
// --------------------------------------------
// Reads in an array of integers, sorts them,
// then prints them in sorted order.
// --------------------------------------------
public static void main (String[] args)
{
Integer[] intList;
int size;
Scanner scan = new Scanner (System.in);
System.out.print ("\nHow many integers do you want to sort? ");
size = scan.nextInt();
intList = new Integer[size];
System.out.println ("\nEnter the numbers...");
for (int i = 0; i < size; i++)
intList[i] = scan.nextInt();
Sorting.insertionSort(intList);
System.out.println ("\nYour numbers in sorted order...");
for (int i = 0; i < size; i++)
System.out.print(intList[i] + " ");
System.out.println ();
}
}