AP计算机教程10-6:困难多选题
0:00
Given the following method declaration, this method will return true if and only if:
public static boolean check(String s)
{
return s.length() >= 2 &&
(s.charAt(0) == s.charAt(1) ||
check(s.substring(1)));
}
s.charAt(0) == s.charAt(1)在开始两个相邻的字符相同时为true,||保证一旦递归过程中有一次为true则整体结果为true。3
Given the following method declaration, what will redo(82, 3) return?
public static int redo(int i, int j)
{
if (i==0)
return 0;
else
return redo(i/j, j)+1;
}
82能被3连除5次,整数除法的结果分别是27、9、3、1、0,除到0时递归终止。1
0 条评论