java中输入三个整数x,y,z,请把这三个数由小到大输出

/**
 * 
 */
package com.gem.demo.day03_practice;

import java.util.Scanner;

/**
 *
 * Description:10.输入三个整数x,y,z,请把这三个数由小到大输出
 *
 * @author HadwinLing
 *
 * @date 2020年1月11日上午10:13:48
 *
 * @version 0.0.1 
 *
 */
public class practice10_01 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		System.out.println("请输入a的值");
		int a = input.nextInt();
		System.out.println("请输入b的值");
		int b = input.nextInt();
		System.out.println("请输入c的值");
		int c = input.nextInt();
		int temp;
		if(a>b) {
			temp = a;
			a=b;
			b=temp;
			
		}
		if(a>c) {
			temp = a;
			a= c;
			c=temp;
			
		}
		if(b>c) {
			temp= b;
			b=c;
			c=temp;
		}
		System.out.println(a+"<"+b+"<"+c);
	}

}

发布了42 篇原创文章 · 获赞 12 · 访问量 6129

猜你喜欢

转载自blog.csdn.net/Alingyuzi/article/details/103935536