我需要以更快的方式确定点的象限。我只知道“确定使用符号”的方法。我正在寻找一个好方法,如果有的话。如果没有任何修补程序对我的代码将有所帮助。假设飞机上有四个四边形。我的代码 -确定点的象限
int x = scan.nextInt() > 0 ? 1 : 0;
int y = scan.nextInt() > 0 ? 1 : 0;
switch (x) {
case 1:
switch (y) {
case 1:
quad = 1;
break;
case 0:
quad = 4;
break;
}
break;
case 0:
switch (y) {
case 1:
quad = 2;
break;
case 0:
quad = 3;
break;
}
break;
}
这功课吗?你有没有实现“确定使用符号”算法?是否存在性能问题(为什么速度不够快?)。告诉我们你的代码。 – Jesper 2012-03-15 10:43:51
@Jesper不是功课。粘贴我的代码。 – sgowd 2012-03-15 10:44:55
好的,为什么它不够快? – Jesper 2012-03-15 10:45:44