我只是没有得到它,为什么时间复杂度是O(n ^ 2)而不是O(n*logn)?第二个循环每次递增2,所以不是O(logn)?
void f3(int n){
int i,j,s=100;
int* ar = (int*)malloc(s*sizeof(int));
for(i=0; i<n; i++){
s=0;
for(j=0; j<n; j+=2){
s+=j;
printf("%d\n", s);
}
free(ar);
}
Run Code Online (Sandbox Code Playgroud)