取三个数的中间值

取三个数的中间值

public class 查找三个数的中间值 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println(f(5, 10, 0));
	}

	private static int f(int a, int b, int c) {
		if ((b - a) * (a - c) >= 0) {
			return a;
		} else if ((a - b) * (b - c) >= 0) {
			return b;
		} else {
			return c;
		}
	}

}

猜你喜欢

转载自blog.csdn.net/a739260008/article/details/86538161
今日推荐