我在网上发现了以下代码,我知道它是b的倍数a 但我在找到复发关系或确定复杂性时遇到问题,所以你可以指导我吗
public int mystery(int a, int b) {
if (b == 0) return 0;
else if (b % 2 == 0)
return mystery(a + a, b / 2);
else return mystery(a + a, b / 2) + a;
}
答案 0 :(得分:0)
递归关系由函数本身定义。我不认为数学符号会有太大差异。
复杂性完全取决于field
,它会以指数方式减少直到停止条件。因此,复杂性将为let tap:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "labelAction:")
mylabel.addGestureRecognizer(tap)
tap.delegate = self // Remember to extend your class with UIGestureRecognizerDelegate
// Receive action
func labelAction(gr:UITapGestureRecognizer)
{
let searchlbl:UILabel = (gr.view as! UILabel) // Type cast it with the class for which you have added gesture
print(searchlbl.text)
}
。