我需要计算下面代码的基本操作:
public static int findmax(int[] a, int x) {
int currentMax = a[0];
for (int i = 1; i < a.length; i++) {
if (a[i] > currentMax) {
currentMax = a[i];
}
}
return currentMax;
}
我知道原始操作(例如为变量赋值)的值是1. 所以这里a[0]为执行的原始操作分配currentMax帐户。1
在 for 循环中:分配1给i,也说明1。和i < a.length,并且i++是n - 1每个(即2(n-1))。但是,我对如何处理该if声明感到困惑。我知道我们正在寻找最坏的情况(因此我们需要执行if条件和嵌套在该块中的语句)。但我不确定这在原始操作方面是什么。