网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
已知程序如下,该程序实现的功能为_____。 (10) main() (20) { int counter; (30) ... //输入N值的语句,假设N为偶数,略 (40) long product = 1; (50) for counter = 1 to N step 2 (60) { product = product * counter; } (70) return product; (80) }
A.product = 1*3*5*...* (N-1)
B.product = 1*2*3*...*(N-1)
C.product = 1+ 2+3+...+ (N-1)
D.product = 1+3+5+...+(N-1)
参考答案和解析
sum = 1!+2!+...+n!
更多 “已知程序如下,该程序实现的功能为_____。 (10) main() (20) { int counter; (30) ... //输入N值的语句,假设N为偶数,略 (40) long product = 1; (50) for counter = 1 to N step 2 (60) { product = product * counter; } (70) return product; (80) }A.product = 1*3*5*...* (N-1)B.product = 1*2*3*...*(N-1)C.product = 1+ 2+3+...+ (N-1)D.product = 1+3+5+...+(N-1)” 相关考题
考题
下面程序的输出结果为( )。struct st { int x; int*y; } *p; int dt[4]={10,20,30,40}; struct st aa[4]={ 50,dt[0],60,dt[1], 70,dt[2],80dt[3]}; main() { p=aa; printf("%d\n",++p-x); printf("%d\n",(++p)-x); printf("%d\n",++(*p-y)); }A.10 B.50 C.51 D.60 20 60 60 70 20 21 21 31
考题
有如下程序:long fib(int n){ if(n2)return(fib(n-1)+fib(n-2));else return(2);}main(){ printf("%d\n",fib(3));}该程序的输出结果是A.2B.4C.6D.8
考题
有以下面程序: include using namespace std; long fib(int n) { if (n>2)return (fi
有以下面程序:include <iostream>using namespace std;long fib(int n){if (n>2)return (fib(n-1)+fib(n-2));elsereturn 2;}int main(){cout<<fib(3)<<endl;return 0;}则该程序的输出结果应该是【 】。
考题
请补充main函数,该函数的功能是:把一个整数插入一个已经按从小到大排序的数组中。插入后,数组仍然有序。 例如,在数组bb[M]={10 20 30 40 50 60 70 80 85 95} 中插入75,结果为 bb[M]={10 20 30 40 50 60 70 75 80 85 95} 注意:部分源程序给出如下。 请勿改动main函数和其他函数中的任何内容,仅在main函数的横线上填入所编写的若干表达式或语句。 试题程序: includestdlib.h includestdio.h define M 10 void main { int i,j; int n; int bb[M+1]={10,20,30,40,50,60,70,80,85,95}; system("CLS"); printf("\nlnput n n"); scanf("%d",&n); printf("\nn=%d",n); printf("\n***original list***\n"); for(i=0;iM;i++) printf("%4d",bb[i]); for(i=0;iM;i++) { if(n=bb[i]) { for(j==M;【1】 ;j--) 【2】 ; bb[j]=n; 【3】 ; } } if(i==M) bb[i]=n: printf("\n****new list****\n"); for(i=0;iM+1;i++) printf("%4d",bb[i]); }
考题
阅读下面程序:include long fib(int n){if (n>2)return (fib(n-1) + fib(n-2));else
阅读下面程序:include <iostream.h>long fib(int n){if (n>2)return (fib(n-1) + fib(n-2));elsereturn (2);}void main(){cout<<fib(3)<<end1;}则该程序的输出结果应该是【 】。
考题
如有下程序:includeusing namespace std;long fun(int n){if(n>2)return(fun(n-1)+fu
如有下程序: #include<iostream> using namespace std; long fun(int n) { if(n>2) return(fun(n-1)+fun(n-2)); else return 2; } int main() { cout<<fun(3)<<endl; return 0; } 则该程序的输出结果应该是( )。A.2B.3C.D.5
考题
有如下程序:includeusing namespace std;long fun(int n){if(n>2)return(fun(n-1)+fu
有如下程序: #include<iostream> using namespace std; long fun(int n) { if(n>2) return(fun(n-1)+fun (n-2)); else return 2; } int main() { cout<<fun(3)<<end1; return 0; } 则该程序的输出结果应该是 ( )。A.2B.3C.4D.5
考题
阅读下面程序: include using namespace std; long fib(int n) {if(n > 2) return(fib
阅读下面程序:include<iostream>using namespace std;long fib(int n){if ( n > 2 )return (fib(n-1)+fib(n-2));elsereturn 2;}int main(){cout<<fib(3)<<end1;return 0;{则该程序的输出结果应该是【 】。
考题
有如下程序: Private Sub Form Click() Dim Check,Counter Check=True Counter=0 Do Do While Counter<20 Counter=Counter+1 If Counter=10 Then Check=False Exit Do End If Loop Loop Until Check=False Print Counter,Check End Sub 程序运行后,单击窗体,输出结果为A.15 0B.20 -1C.10 TreeD.10 False
考题
请编写一个函数inline long sum(int n),用递归函数完成运算:sum(n)=1*1+2*2+…n*n,递归表达式为 sum(n)=sum(n-1)+n2。注意:部分源程序已存在文件test10_2.cpp中。请勿修改主函数main和其他函数中的任何内容,仅在函数sum的花括号中填写若干语句。文件test10_2.cpp的内容如下:include<iostream.h>inline long sum(int n){}void main(){int n;cout<<"输入n:";cin>>n;cout<<"结果为:"<<sum(n)<<endl;}
考题
阅读下面利用递归来求n!的程序 class FactorialTest { static long Factorial(int n){ //定义Factorial()方法 if(n==1)return 1; else return n * Factorial(______); } public static void main(String a[]) { //main()方法 int n=8; System.out.println(n+"!="+Factorial(n)); } } 为保证程序正确运行,在下画线处应该填入的参数是A.n-1B.n-2C.nD.n+1
考题
有如下程序:includelong fib(int n){if(n>2)return(fib(n-1)+fib(n-2)); else retu
有如下程序: #include<iostream.h> long fib(int n) { if(n>2)return(fib(n-1)+fib(n-2)); else return(2);} void main( ) {cout<<fib(3);} 该程序的输出结果是A.2B.4C.6D.8
考题
有以下程序:include int fun(int n){if(n == 1) return 1;else return( n + fun( n -
有以下程序:#include <stdio.h>int fun(int n){ if(n == 1) return 1; else return( n + fun( n - 1 ) );}main( ){ int x; seanf("% d" ,X) ;x = fun(x) ;pfinff( "% d \n" ,x);} 执行程序时,给变量x输入10,程序的输出结果是( )。A.55B.54C.65D.45
考题
有如下程序:includelong fib(int n){if(n>2)return(fib(n-1)+fib(n-2)); else return(
有如下程序: #include <stdio.h> long fib(int n) { if(n>2)return(fib(n-1)+fib(n-2)); else return(2); } main() { printf("%d\n",fib(3));} 该程序的输出结果是( )。A.2B.4C.6D.8
考题
有以下程序:includeusing namespace std;int n[][3]={10,20,30,40,50,60};int main()
有以下程序: #include<iostream> using namespace std; int n[][3]={10,20,30,40,50,60}; int main() { int (*p)[3]; p=n; cout<<p[0] [0]<<","<<*(p[0]+1)<<","<<(*p) [2]<<end1; return 0; } 上述程序执行后的输出结果是( )。A.10,20,30B.20,30,40C.10,30,50D.10,40,60
考题
有如下的程序段,该程序段执行完后,共执行的循环次数是 total=0 Counter=1 Do Print Counter total=total * Counter + 1 Print total Counter=Counter +1 If total > 10 Then Exit Do End If Loop While Counter<=10A.4B.10C.15D.20
考题
有如下程序段,该程序段执行完后,执行循环的次数是 total=0 Counter=1 Do Print Counter total=total + Counter Print total Counter=Counter+1 If total>10 Then Exit Do End If Loop While Counter <=10A.5B.10C.15D.20
考题
有如下的程序段,该程序段的执行完后,共执行循环的次数是 Private Sub Command1_Click() total=0 Counter=l Do Print Counter total=total+Counter Print total Counter=Counter+1 If total>=10 Then Exit Do End If Loop While Counter<=10 End SubA.5B.10C.12D.20
考题
有如下程序 long fib(int n) { if(n>2)return(fib(n-1)-fib(n-2)); else return(1); } main() { printf("%d\n",fib(5)); }该程序的输出结果是______。A.-3B.-2C.-1D.0
考题
有如下程序: Private Sub Form_C1ick() Dim CheCk,Counter CheCk=True Counter=0 Do Do While Counter<20 Counter=Counter+1 If Counter=10 Then Check=False Exit Do End If Loop Loop Until Check=False Ptint Counter,Check End Sub 程序运行后,单击窗体,输出结果为______。A. 15 0B.20 -1C.10 TreeD.10 False
考题
有如下程序______。 long fib (int n) { if(n>2) returb(fib(n-1)+fib(n-2)); else return(2); } main() {printf("%d\n",fib(3));} 该程序的输出结果是______。A.2B.4C.6D.8
考题
有程序: long fib(int n) { if(n<2)return(fib(n-1)+fib(n-2)); else return(2); } main( ) {printf("%d\n",fib(3));} 该程序的输出结果是( )A.2B.4C.6D.8
考题
有如下程序段,该程序段执行完后,共执行循环的次数是 Private Sub Command1_Click( ) Tota1=0 Counter=1 Do Print Counter Tota1=tota1+Counter Print total Counter=Counter+1 If total=10 Then Exit Do End lf Loop While Counter<=10 End SubA.5B.10C.12D.20
考题
有如下程序:includeusing namespace std;long fib(int n){ if(n>2) return(fib(n-1)+
有如下程序: #include<iostream> using namespace std; long fib(int n) { if(n>2) return(fib(n-1)+fib(n-2)); else return(n); } void main() { int i; cout<<"请输入一个整数:"; cin>>i;cout<<endl; cout<<fib(i)<<endl; { 当输入4、2时,该程序的输出结果是( )。A.5B.4C.5D.6 1 2 2 2
考题
有以下程序 include using namespace std; long fib(int n) { if(n>2) return(fib(n-1
有以下程序include<iostream>using namespace std;long fib(int n){if(n>2)return(fib(n-1)+fib(n-2));elsereturn 2;}int main( ){cout<<fib(3)<<endl;return 0;}则该程序的输出结果应该是______。
考题
阅读下列说明和 C++代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
生成器( Builder)模式的意图是将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示。图 5-1 所示为其类图。
【C++代码】
#include
#include
using namespace std;
class Product {
private:? ??
string partA, partB;
public:
Product() {?? }
? ? ?void
setPartA(const string}
???? void
setPartB(const string}
//? 其余代码省略
};
class Builder {
public:
??????? (1)?? ;
virtual void buildPartB()=0;
??????? (2)?? ;
};
class ConcreteBuilder1 : public Builder {
private:
Product*?? product;
public:
ConcreteBuilder1() {product = new Product();???? }
??? void
buildPartA() {????? (3)???? ("Component A"); }
??? void
buildPartB() {????? (4)???? ("Component B"); }
Product* getResult() { return product; }
//? 其余代码省略
};
class ConcreteBuilder2 : public Builder {? ??
/*??? 代码省略??? */
};
class Director {
private:?
Builder* builder;
public:? ?
Director(Builder* pBuilder) { builder= pBuilder;}
???? void
construct() {
? ? ? ? ? ? ? (5)???? ;? ? ?
//? 其余代码省略
????? }
//? 其余代码省略
};
int main() {
Director* director1 = new Director(new ConcreteBuilder1());?
director1->construct();? ?
delete director1;? ??
return 0;
考题
有如下程序 long fib(int n) { if(n2) return(fib(n-1)+fib(n-2)); else return(2); } main() { printf("%ld/n",fib(3)); } 该程序的输出结果是()A、2B、4C、6D、8
考题
单选题有如下程序 long fib(int n) { if(n2) return(fib(n-1)+fib(n-2)); else return(2); } main() { printf("%ld/n",fib(3)); } 该程序的输出结果是()A
2B
4C
6D
8
热门标签
最新试卷