static int test(int testval) { int result = 0; if(testval > target) result = -1; else if(testval < target) result = +1; else result = 0; // match return result;}
static int test2(int testval) { if(testval > target) return -1; if(testval < target) return +1; return 0; // match}不必加上else,因为方法在遇到return后便不再继续。
欢迎光临 精易论坛 (https://125.confly.eu.org/) | Powered by Discuz! X3.4 |