【单选题】程序段 i=0;s=0; while(i<=n) { int p="1;" for(j="0;" j++) p*="j;" s="s+p;" } 该程序段的时间复杂度为 ()> A、O(n)
B、O(n*logn)
C、O(n*n*n)
D、O(n*n)
B、O(n*logn)
C、O(n*n*n)
D、O(n*n)
有如下程序: #include <iostream> using namespace std; class Stack { public: Stack(unsigned n= 10):size(n) {rep_=ew int[size]; top=0;} Stack(Stack& s):size(s.size) { rep_=new int[size]; for(int i=0;i<size;i++) rep_[i]=s.rep_[i]; top=s.top; } ~Stack() {delete[]rep_;} void push(int a) {rep_[top]=a; top++;} int pop() {--top;return rep_[top];} bool isEmpty() const {return top==0;} private: int *rep_; unsigned size,top; }; int main() { Stack s1; for(int i= 1;i<5 ;i++) s1. push(i); Stack s2(s1); for(i= 1 ;i<3;i++) cout<<s2.pop()<<','; s2.push(6); si.push(7); while(!s2.isEmpty()) cout<<s2.pop()<<','; return 0; }执行上面程序的输出是______ 。
A.4,3,2,1,
B.4,3,6,7,2,1,
C.4,3,6,2,1,
D.1,2,3,4,
例如,str="abc3de987f9621",结果为:3987621。
注意:部分源程序给出如下。
请勿改动main函数和其他函数中的任何内容,仅在函数proc的横线上填入所编写的若干表达式或语句。
试题程序:
include
define M 80
int bb[M];
int proc(char str[],int bb[],int num)
{
int i,n=0;
for(i=0;i
{
if(【1】)
{
bb[n]=【2】:
n++:
}
}
return 【3】 ;
}
void main
{
char str[M];
int mum=0,n,i;
printf("Enter a strin9:\n");
gets(str);
while(str[num])
num++:
n=proc(str,bb,num);
printf("\nbb=");
for(i=0;i
printf("%d",bb[i]);
}
B、9
C、15
D、12
A、m=2
B、m=4
C、m=6
D、m=5
include
main()
{ int n[2],i,j;
for(i=0;i<2;i++)n[i]=0;
for(i=0;i<2;i++)
for(j=0;j<2;j++)n[j]=n[i]+1;
printf("%d\n",n[1]);
}
为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!