JAVA经典算法(十五)

题目:输入三个整数x,y,z,请把这三个数由小到大输出。

package cn.ls.lanqiao;

import java.util.*;

public class Test15 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int t = 0;
		if (a > b) {
			t = a;
			a = b;
			b = t;
		}
		if (a > c) {
			t = a;
			a = c;
			c = t;
		}
		if (b > c) {
			t = b;
			b = c;
			c = t;
		}
		System.out.println(a + " " + b + " " + c);
	}

}

 

posted @ 2020-01-15 22:30  小帅学java  阅读(8)  评论(0)    收藏  举报