题目:
三个整数 比较大小
答案:
class Daxiao {
public static void main(String[] args) {
int x=1654,y=987,z=988;
if(x>y) {
if(y>z){
System.out.println("x>y>z");
}
else
if(x>z) {
System.out.println("x>z>y");
}
else {
System.out.println("z>x>y");
}
}
else {
if(z<x) {
System.out.println("y>x>z");
}
else if(y>z) {
System.out.println("y>z>x");
}
else {
System.out.println("z>y>x");
}
}
}
}
以前用C语言编过,不过具体怎么实现的忘记了,现在看来,这个程序看着有点乱,但是能实现,不知道还有没有更加简洁的方法.