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);
	}
}
发布了151 篇原创文章 · 获赞 164 · 访问量 9778

猜你喜欢

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