package test.yzy;
public class TestMaxMix {
/**
* @param args
*/
public static void main(String[] args)
{
int a=22, b=111, c=9;
test(a,b,c);
}
private static void test(int a, int b, int c)
{
int maxB;
int mixB;
if (a>b)
{
maxB = a;
mixB = b;
}
else
{
maxB = b;
mixB = a;
}
if (maxB > c)
{
}
else
{
maxB = c;
}
if (mixB < c)
{
}
else
{
mixB = c;
}
System.out.println("最大值:" + maxB + "最小值:" + mixB);
}
}
写个不用if-else的吧
max=(a>b?a:b)>c?(a>b?a:b):c
min=(a>b?b:a)>c?c:(a>b?b:a)
一楼正解!