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);
	}

}
发布了151 篇原创文章 · 获赞 164 · 访问量 9796

猜你喜欢

转载自blog.csdn.net/ls_wifi/article/details/103997025
今日推荐