3、在以下语句段中,若 i >= n 计算结果为True,而且 n 不是 i 的倍数。则下列语句中可能执行到的语句是______。 test: loop if n % i = 0 then set yn = 0 ; leave test ; end if ; set i = i+1 ; if i >= n then leave test ; end if ; end loop test ;A.set yn = 0 ;B.第一个if语句中的“leave test ;”C.第二个if语句中的“leave test ;”D.set i = i+1 ;

3、在以下语句段中,若 i >= n 计算结果为True,而且 n 不是 i 的倍数。则下列语句中可能执行到的语句是______。 test: loop if n % i = 0 then set yn = 0 ; leave test ; end if ; set i = i+1 ; if i >= n then leave test ; end if ; end loop test ;

A.set yn = 0 ;

B.第一个if语句中的“leave test ;”

C.第二个if语句中的“leave test ;”

D.set i = i+1 ;


参考答案和解析
分析程序中各变量、各语句的作用, 再根据流程图所示的顺序,可知: 该程序的作用是计算并输出分段函数 y= 2a,a≥10 a 2 ,a<10 的函数值. 当a=3时,程序段输出的结果是y=3 2 =9 故选A.

相关考题:

下面程序的运行结果是【】。 inChlde using namespace std; class count { static int n; 下面程序的运行结果是【 】。inChlde<iOStream>using namespace std;class count{static int n;public:count(){n++;}static int test(){for(int i=0:i<4;i++)n++;return n;}};int count::n=0;int main(){cout<<COUnt::test()<<" ";count c1, c2;cout<<count::test()<<end1;return 0;}

执行下面程序段,语句3的执行次数为______。for(i=0;ii;j++)state;A.n(n+2)/2B 执行下面程序段,语句3的执行次数为______。 for(i=0;i<n-1;i++) for(j=n;j>i;j++) state;A.n(n+2)/2B.(n-1)(n+2)/2C.n(n+1)/2D.(n-1)(n+2)

(12)下列程序段的运行结果是 Sub sele() Dim n As Integer I=21:n=3 Do While in I=i-n Loop Print i End SubA.2 B.4 C.5 D.3

(11)下列程序用于在带垂直滚动条的文本框Text1中输出3到100之间的全部素数。请填空。 Private Sub Command1_Click() Text1.Text="" For n=3 To 100 k=Int(Sqr(n)) i=2 Flag=0 Do While i= And Flag=0 If n Mod i=0 Then Flag=1 Else i=i+1 End If Loop If Then Text1.Text=Text1.TextStr(n)Chr(13)Chr(10) End If Next n End Sub

下面程序的运行结果是【】。 include using namespace std; class count{ static int n; 下面程序的运行结果是【 】。include <iostream>using namespace std;class count{static int n;public:count(){n++;}static int test(){for(int i=0;i<4;i++)n++;return n;}};int count::n = O;int main(){cout<<count:: test()<<" ";count c1, c2;cout<<count:: test()<<endl;return 0;}

使用VC6打开考生文件夹下的工程test37_1,此工程包含一个源程序文件test37_1.cpp,但该程序运行有问题,请改正函数中的错误,使该程序的输出结果为:0149 16 25 36 49 64 81源程序文件test37_1.cpp清单如下:include<iostream.h>template <class T, int N = 100> class Vector{T vec[N];public:void set(int pos, T val);T get(iht pos);/***************** found *****************/}template <class T, int N> void Vector<T, N>::set(int pos, T val){vec[pos] = val;}/***************** found *****************/template <class T, int N> Vector<T, N>::get(int pos){return vec[pos];}int main (){Vector<double, 10> v;int i = 0;double d = 0.0;for (i = 0; i < 10; i++)v.set(i, double(i * i));for (i = 0; i < 10; i++)cout<<v.get(i)<<" ";cout<<end1;/***************** found *****************/}

使用VC6打开考生文件夹下的工程test25_3,此工程包含一个源程序文件test25_3.cpp,其中定义了用于表示堆的类Set,但它的定义并不完整。请按要求完成下列操作,将程序补充完整。(1)完成成员函数int IsMemberOf(int n)的定义,该函数检查参数n是否在类的数据成员数组elems中,如果在返回1,反之返回0。请在注释“//**1**”之后添加适当的语句。(2)完成成员函数int Add(int n)的定义,如果参数n包含在类的数据成员数组elems中则返回1如果数组超界则返回0,如果都不是,则将参数n插入到elems中,下标大小为类的数据成员PC,之后PC自加一。请在注释“//**2**”之后添加适当的语句。(3)完成拷贝初始化构造函数Set(Set s)的定义,请在注释“//**3**”之后添加适当的语句。输出结果如下:1{}{1,2,3,4,5,6,7,8}注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。源程序文件test25_3.cpp清单如下:include<iostream.h>class Setpublic:Set() {PC=O;}Set(Set s);void Empty() {PC=O;}int IsEmpty() {return PC==O;}int IsMemberOf(int n);int Add(int n);void Print();private:int elems[100];int PC;};int Set::IsMemberOf(int n){//**1**if(elems[i]==n)return 1;return O;}int Set::Add(int n){//**2**return 1;else if(PC>=100)return O;else{elems[PC++]=n;return 1;}}Set::Set(Set s){//**3**for(int i=O; i<PC; i++)elems[i]=s.elems[i];}void Set::Print(){cout<<"{";for(int i=O; i<PC-1; i++)cout<<elems[i]<<",";if(PC>O)cout<<elems[PC-1];cout<<"}"<<endl;}void main(){Set A;cout<<A.IsEmpty()<<endl;A.Print();Set B;for(int i=l; i<=8; i++)B.Add(i);B.Print();}

以下能够正确计算n!的程序是A.Private Sub Command1_Chck( ) n=5:x=1 Do x=x*i i=i+1 Loop While i<n Print x End SubB.Private Sub Command1_Click( ) n=5:x=1:i=l Do x=x*i i=i+1 Loop While i<n Print x End SubC.Private Sub Command1_Click( ) n=5:x=1:i=l Do x=x*i i=i+1 Loop While i<=n Print x End SubD.Private Sub Command1_Click( ) n=5:x=1:i=l Dox=x*i i=i+1 Loop While i>n Print x End Sub

以下能够正确计算n!的程序是A.Private Sub Command1 Click() n=5:x=1 Do x=x * I I=I + 1 Loop While I < n Print x End SubB.Private Sub Command1_Click() n=5:X=1:I=1 Do X=X*I I=I + 1 Loop While I <n Print x End SubC.Private Sub Command1_Click() n=5:X=1:I=1 Do X=X * I I=I + 1 Loop While I<=n Print X End SubD.Private Sub Command1_Click() n=5:X=1:I=1 Do x=x * I I=I + 1 Loop While I>n Print X End Sub

以下能够正确计算n! 的程序是( )。A.Private Sub Command1_Click( ) n=5:x=l Do x=x*i i=i+1 Loop While i < n Print x End SubB.Private Sub Command1_Click( ) n=5:x=1:i=1 Do x=x*i i=i+1 Loop While i < n Print x End SubC.Private Sub Command1_Cliek( ) n:5:x=1:i=1 Do x=x* i i:i+1 Loop While i < = n Print x End SubD.Private Sub Command1_Cliek( ) n=5:x:1:i=1 Do x=x*i i=j+1 Loop While i > n Print x End Sub

下列程序段的运行结果是( )。 Subsele() Dim n As Integer i=21:n=3 Do While i>n i=i-n Loop Print i End SubA.2B.4C.5D.3

有如下程序:include usingnamespacestd:class Test{public: Test(){n+=2; ~Test(){n- 有如下程序:#include <iostream>using namespace std:class Test{public: Test() {n+=2; ~Test() {n-=3; ; static int getNum() {return n;}privaue: static int n:};int Test::n=1;int main(){ Test* p=new Test; delete p; cout<<"n="<<Test::getNum()<<end1; return 0;} 执行后的输出结果是A.n=0B.n=1C.n=2D.n=3

以下能够正确计算1+2+3+…+10的程序是A.Private Sub Command1_Click() Sum=0 ForI=1 To 10 Sum=Sum+I Next I Print Sum End SubB.Private Sub Command1_Click() Sum=0,I=1 Do While I<=10 Sum=Sum+I I=I+1 Print Sum End SubC.Private Sub Command1_Click() Sum=0: I=1 Do Sum=Sum+I I=I+1 Loop While I<10 Print Sum End SubD.Private Sub Command1_Click() Sum=0: I=1 Do Sum=Sum+I I=I+1 Loop Until I<10 Print Sum End Sub

有以下程序:include using namespace std;class count{ static int n;public: count 有以下程序: #include <iostream> using namespace std; class count { static int n; public: count ( ) { n++; } static int test() { for (int i = 0; i < 4; i++ ) n++; return n; } }; int count :: n = 0; int main() { cout<<count :: test()<<" "; count c1, c2; cout<<count :: test()<<end1; return 0; } 执行后的输出结果是( )。A.4 10B.1 2C.22D.24

6 写出下列程序在X86 上的运行结果。struct mybitfields{unsigned short a : 4;unsigned short b : 5;unsigned short c : 7;}testvoid main(void){int i;test.a=2;test.b=3;test.c=0;i=*((short *)test);printf("%d\n",i);}

有如下程序: include using namespace std;class Test {public: Test() {n+=2;} ~Tes 有如下程序: #include <iostream> using namespace std; class Test { public: Test() {n+=2;} ~Test() {n-=3;} static int getNum(){retum n;} private: static int n; }; int Test:: n=1; int main() { Test*p=new Test; delete p; cout<<"n="<<Test:: getNum()<<end1; return 0; };执行后的输出结果是______.A.n=0B.n=1C.n=2D.n=3

单击命令按钮后,下列程序代码的执行结果是______。Public Sub fun (a As Integer, b As Integer, c As Integer)Doa=b+ cn=n+1Loop While n > 3End SubPrivate Sub command1_ click()Dim m As Integer, n As Integer, i As IntegerFor i = 0 To 2: m = n + 1: Next iFor i = 1 To 2: Call fun (m, n, i): Next iFor i = 0 To 3Print m;Next iEnd Sub

下列程序段的运行结果是( )。 Sub sele() Dim n As Integer i=21: n=3 Do While i > n i=i-n Loop Print i End SubA.2B.4C.5D.3

有如下程序 main( ) {int n[5]={0,0,0},i, k=2; for(i=0 i<k i++)n[i]=n[i]+1; cout<<n[k]<<end1; }该程序的输出结果是A.不定值B.2C.1D.0

以下能够正确计算n!的程序是______。A.Private Sub Commeadl_Click() n=5: x=1 Do x=x*i i=i+1 Loop While i<n Print x End SubB.Private Sub Command1_Click() n=5: x=1: i=1 Do x=x*i i=i+1 Loop While i<n Print x End SubC.Private Sub Command1_Click() n=5: x=1: i=1 Do x=x*i i=i+1 Loop Whilei<=n Print x End SubD.Private Sub Commsndl_Click() n=5: x=1: i=1 Do x=x*i i=i+1 Loop While i>n Print x End Sub

下面程序的运行结果是()。includeusing namespace std;class TestClass{static int n; 下面程序的运行结果是( )。 #include<iostream> using namespace std; class TestClass { static int n; public: TestClass () { n++; } static int test() { for(int i=0;i<4;i++) n++; return n; } }; int TestClass::n=0; int main() { cout<<TestClass::test()<<" "; TestClass c1,c2; cout<<TestClass::test()<<endl; return (); }A.4,10B.4,6C.0,6D.0,4

以下能够正确计算n!的程序是( )。A.Pfivate Sub Commgld1_LClick() n=5:x=1 Do x=x*1 i=i+1 Loop Whilei<nB.Private Sub Command1_Click() n=5:x=1:i=1 Do x=x*1 i=i+1 Loop Whilei<n Print x End SubC.Pfivate Sub Command1_ C1ick() n=5:x=1:i=1 Do X=X*1 i=i+1 Loop While i<=nD.Private Sub Command1_C1ick() n=5:x=1:i=1 Do X=X*1 i=i+1 Loop While i>n Print x End Sub

以下能够正确计算1+2+3+…+10的程序是A.Private sub Command1_Click( ) sum=0 For 1=1 To 10 Sum=sum+1, Next I Print Sum End SubB.Private sub Command1_Click( ) Sum=0,I=1 Do While l<=10 Sum=Sum+1 I=I+1 Print Sum End SubC.Private Sub command1_click( ) Sum=0:I=1 Do Sum=Sum+1 I=I+1 Loop While I<10 Print Sum End SubD.Private Sub command1_Click( ) Sum=0:I=1 Do Sum=Sum+1 l=I+1 Loop Until I<10 Print Sum End Sub

以下能够正确计算n!的程序是( )。A.Private Sub Commandl_C1ick()B.hiVate Sub Commandl_C1ick() n=5:x=1 n=5:x=1:i=1 DO DO X=x*1 X=X*1 i=i+1 i=i+1 Loop while i<n Loop While<n Print x Ptinte x End Sub End SubC.Private Sub Commandl_Click ()D.Pdvate Sub Commandl C1ick() n=5:X=1:i=1 n=5=:x=1:i=1 DO DO X=X*1 X=X*1 i=i+1 i=i+1 Loop While i>n Print x Print x End Sub End Sub

在下面循环语句中循环体执行的次数为(46)。for(int i=0;in/2)break;A.n/2B.n/2+1C. 在下面循环语句中循环体执行的次数为(46)。 for(int i=0;i<0; i+ +)if(i>n/2)break;A.n/2B.n/2+1C.n/2-1D.n-1

假设执行语句S的时间为0(1),则执行下列程序段的时间为( )。for(i=l; k=n; it+) for(j=l;j S;A.0(n)B.0(n^2)C.O(n×i)D.0(n+1)

填空题下列程序的运行结果是()。  Program test  Implicit none  Integer::i  Integer::a(5)=(/ (i, i=1,5) /)  Integer::b(5)=0       Where (a3)            b=a     End where  Write(*,”(5(i3,1x))”) b  end

填空题下列程序的运行结果是()。  Program test  Implicit none  Integer::i  Integer::a(5)        Forall ( i=1:5 )     A(I)=5  End forall  Write(*,*)a  Stop  end