网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
已知程序如下,该程序实现的功能为_____。 (10) main() (20) { int counter; (30) ... //输入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值的语句,略 (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)” 相关考题
考题
有如下程序: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;}则该程序的输出结果应该是【 】。
考题
阅读下面程序: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
考题
有如下程序段,该程序段执行完后,执行循环的次数是total=0Counter=1DoPrint Countertotal=total + CounterPrint totalCounter=Counter + 1If total 10 ThenExit DoEnd IfLoop While Counter =10( )。A.5B.10C.15D.20
考题
阅读下面程序: 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, CounterCheck = TrueCounter = 0DoDo While Counter 20Counter = Counter + 1If Counter = 10 ThenCheck = FalseExit DoEnd IfLoopLoop Until Check = FalsePrint Counter, CheckEnd Sub程序运行后,单击窗体,输出结果为( )。A.15 0B.20 -1C.10 TrueD.10 False
考题
有如下程序: 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
考题
阅读下面的程序:PriVate Sub Form_C1ick()Dim Check As Booleau,Counter As IntegerCheck=TrueCounter=5DoDo While Counter<20Counter=Counter+1If Counter=10 ThenCheck=FalSeEXit Do
考题
有如下程序: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
考题
有如下程序: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 Command1_ 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 MsgBox CounterEnd Sub 程序最后弹出的消息对话框的内容是______。A.TrueB.FalseC.20D.10
考题
有如下程序: 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;
考题
阅读下列说明和 Java 代码,将应填入(n)处的字句写在答题纸的对应栏内。
【说明】
生成器( Builder)模式的意图是将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示。图 6-1 所示为其类图。
阅读下列说明和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;
【Java代码】
import jav(6)A.util.*;
class Product {? ? ? ?
private String partA;? ? ? ?
private String partB;? ? ? ??
public Product() {}? ? ??
public void setPartA(String s) { partA = s; }? ? ? ?
public void setPartB(String s) { partB = s; }
}
interface Builder {? ?
public?????? (1)???? ;? ??
public void buildPartB();? ? ??
public?????? (2)???? ;
}
class ConcreteBuilder1 implements Builder {? ? ? ?
private Product product;? ? ? ?
public ConcreteBuilder1() { product = new Product();?? }? ? ? ??
public void buildPartA() {????????
(3)??
("Component A"); }
public void buildPartB() {???? ????(4)?? ("Component B"); }? ? ??
public Product getResult() { return product;}
}
class ConcreteBuilder2 implements Builder {?? ? ? ? ?
//? 代码省略
}
class Director {? ? ? ?
private Builder builder;? ? ? ?
public Director(Builder builder) {this.builder = builder; }
public void construct() {
? ? ? ? ? ? ? ? ? (5)???? ;
? ? ? ? ? ? ? //? 代码省略? ? ??
}
}
class Test {? ? ??
public static void main(String[] args) {
???????????????? Director director1 = new
Director(new ConcreteBuilder1());
???????????????? director1.construct();? ? ? ??
}
考题
有如下程序 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
热门标签
最新试卷