单选题

对下面两个函数,说法错误的是(    )。

int sumA(int n) {

      int res = 0;

      for (int i = 1; i <= n; i++) {

            res += i;

      }

      return res;

}

int sumB(int n) {

      if (n == 1)

            return 1;

      int res = n + sumB(n - 1);

      return res;

}

A

sumA体现了迭代的思想。

B

SumB采用的是递归方式。

C

SumB函数比SumA的时间效率更高。

D

两个函数的实现的功能相同。

赣ICP备20007335号-2