java Blue Bridge Cup practice

Title: write a program, input three integers, then the program will be arranged according to the three largest to smallest integer.
Input format: input single line, i.e. three integers, separated by a space.
Output formats: Output only one line, that is the result of the sort.
Sample input and output
sample input
9230
sample output
3092

(first published article, there is something wrong may raise with me, thank you)

import java.util.Scanner;
public class lianxi_11 {
	public static void main(String[] args) {
		Scanner shuruScanner=new Scanner(System.in);
		int[] shu=new int[3];
		for (int i = 0; i < shu.length; i++) {
			shu[i]=shuruScanner.nextInt();
		}
				for (int i = 0; i < shu.length; i++) {
			for (int j = 0; j <i; j++) {
				if (shu[i]>shu[j]) {
					int temp=shu[j];
					shu[j]=shu[i];
					shu[i]=temp;
				}
			}
		}
		for (int i = 0; i < shu.length; i++) {
			System.out.print(shu[i]+"\t");
		}
	}
}

Published 23 original articles · won praise 0 · Views 442

Guess you like

Origin blog.csdn.net/ThoughtsofXin/article/details/104169679