For the following piece of code
for(i=0; i<n; i++)
for(j=i; j>0; j/=2)
printf(“%d\n”, j);
the time complexity is:
选项:
A:
O(N×i)
B:
O(N)
C:
O(N2)
D:
O(NlogN)
for(i=0; i<n; i++)
for(j=i; j>0; j/=2)
printf(“%d\n”, j);
the time complexity is:
O(N×i)
O(N)
O(N2)
O(NlogN)
以下文字与答案无关
提示:有些试题内容 显示不完整,文字错误 或者 答案显示错误等问题,这是由于我们在扫描录入过程中 机器识别错误导致,人工逐条矫正总有遗漏,所以恳请 广大网友理解。
sort(a,5);
printf("Now,the sequence is:\n");
for(i=0;i<n;i++)
printf("%d ",ai]);
}
void sort(int a],int n) //冒泡排序,从小到大排
{ int i, j;
int temp;
for( i = 1; i < n; i++ )
for (j = 0; j < n-i; j++ )
if (*(a+j) > *(a+j+1))
{ temp=*(a+j) ;
*(a+j)=*(a+j+1);
*(a+j+1)=temp;
}
}
">1.19. 分析下面的程序,如果输入25 66 44 12 99,写出运行结果。#include<stdio.h>
void sort(int a],int n);
int main(){
int a5];
int i;
for(i=0;i<5;i++)
scanf("%d",&ai]);
sort(a,5);
printf("Now,the sequence is:\n");
for(i=0;i<n;i++)
printf("%d ",ai]);
}
void sort(int a],int n) //冒泡排序,从小到大排
{ int i, j;
int temp;
for( i = 1; i < n; i++ )
for (j = 0; j < n-i; j++ )
if (*(a+j) > *(a+j+1))
{ temp=*(a+j) ;
*(a+j)=*(a+j+1);
*(a+j+1)=temp;
}
}
K e y s t o n e
B:N e u t r o n
C:C i n d e r
D:S w i f t
TE(i)+t(i, j)
B:TL(j)-ty
C:TL(j)
D:TL(j)+ty