下面程序段的时间复杂度为()。voidsum(intn)//n为正整数{intp=1,sum=0,i;for(i=1;i=n;i ){p*=i;sum =p;}}
A.O()
B.O(n)
C.O(1)
D.O(n^2)
正确答案:O(n)
猜你喜欢