标签:java
import java.util.Scanner; public class Test { 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(b);//先排序再输出排序后的中间数b //int zhong= a>b?(a<c?a:(b>c?b:c)):(b<c?b:(a>c?a:c));//三目运算符 //System.out.println(zhong); } }
Java编程:用三目运算符和交换两种方法求三个数中的中间数字。
标签:java
原文地址:http://blog.csdn.net/u012110719/article/details/41171851