/**
* 7-1
* The program that writes the character interface, accepts a number of positive integers entered by the user,
*-1 indicates the end of the input.
* Sort the input data in descending order using the sort algorithm
* and print the results after each scan
* The runtime uses the following different data series to observe its execution results
* 1. There is only one data in the sequence
* 2. Duplicate data in a sequence
* 3. The data entered in the sequence is sorted in ascending order
* 4. The data entered in the sequence is sorted in descending order
**/
Import java.util.*;p Ublic class Test {public static void main (string[] args) {Scanner input=new Scanner (system.in); int i = 0, S = 0;int array[] = new INT[100]; System.out.println ("Enter several positive integers, ending with 1");/* Enter several integers */while ((s = input.nextint ()) =-1) array[i++] = s;/* Sorts the input data using the Bubbling Sorting algorithm */for (int j = 0; J < i; J + +) {for (int k = 0; k < i-j-1; k++) {int temp = 0;IF (Array[k] < array [K+1]) {temp = array[k];array[k]=array[k+1];array[k+1]=temp;}} for (int l = 0; l < i; l++) System.out.print ("" + Array[l] + ""); System.out.println ();}}}
Those years, learn together Java 7-1