JAVA经典算法(三十四)

 题目:输入3个数a,b,c,按大小顺序输出。

package cn.ls.lanqiao;

import java.util.Scanner;

public class Test34 {

	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;
		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-26 22:11  小帅学java  阅读(7)  评论(0)    收藏  举报