【发布时间】:2012-07-14 02:38:01
【问题描述】:
我想找出三个给定数字中最大的数字,使用 switch-case(不使用 if) 我使用这个程序回答了这个问题,它有效:
class GreatestNoSwitch{
public int main(int a, int b, int c){
int d = (int)Math.floor(a/b);
int max = 0;
switch(d){
case 0:
max = b;
break;
default:
max = a;
}
d = (int)Math.floor(max/c);
switch(d){
case 0:
max = c;
}
return max;
}
}
有人有更简单的答案吗?
【问题讨论】:
-
您的问题是什么?你的代码有效吗?
-
StackOverflow 是
Question&Answering站点。发布question,我们会尽力寻找答案或至少帮助您找到答案。 -
如果不限制允许的功能,这个问题没有多大意义。