鸭子tv国产极品在线观看_成人69视频在线播放_91精品免费在线观看_亚洲AT永久偷窥无码精品_国产精品自产拍在线观看涩浪潮久

江蘇省高校計算機等級考試命題研究院 江蘇省高校計算機等級考試輔導(dǎo)
江蘇計算機等級考試vc++沖刺模擬試題1

第二部分:Vc++程序設(shè)計

 C++語言程序設(shè)計理論部分

  一、選擇題(30)

  21•設(shè)有定義“float y=5.16347;int x;”,則以下表達式中可以實現(xiàn)將y中的數(shù)值保留小

數(shù)點后2位,將第三位四舍五人的表達式是_____________

  Ay=(y*100+0.5)/100.0     Bx=y*lOO+O.5,y=x/lOO.0

  Cy=y*100+0.5/100.0       Dy=(y/100+0.5)*100.0

  22.設(shè)有說明語句"int a=6;float b=l,c=l;",則表達式"c%=(b=a/=4),a+=3"

的值為_________

    A9    B1.5     C1         D.編譯有錯

 2 3.關(guān)于字符串,以下說法正確的是 __________

    A.字符串"abc\t\"op\\"中實際的字符個數(shù)為8

    B.字符串是以0結(jié)尾的字符數(shù)組

    Csizeof("abc\O\"op\\")=3

    Dstrlen("abc\O\"op\\")=8

  24.已定義"int a[5]={lOO200,300,400,500};int *P1=&a[0]",b=*++P1,則b*P1的值分別為___。

 

    A100 200    B200 200    C)101 101 D100 101

  25.下面給出的程序的輸出結(jié)果不正確的是 _________ 。

   Achar *sl,s2[]="123";  sl=s2;  cout<<*sl;,結(jié)果:123

   B. char *sl,s2[]="123";sl=s2;  cout<<sl;結(jié)果:123

   Cchar *sl="123\0tear";cout<<s1;結(jié)果:123

   Dchar s1[]="567",s2[]=123;strcpy(sl,s2)cout<<s1;結(jié)果:123

  26.設(shè)有變量說明“int a[][2]={{2,5},{48}};int *pa,(*pb)[2];"則執(zhí)行語句"pa=&a[0][0];pb=a;"后,

(*(pa+1))(*(pb+1))的值為:______

  A5,4    B&a[1][0],4   C5,&a[1][0]    D. &a[0][1], &a[1][0]

 2 7.下列關(guān)于數(shù)組的應(yīng)用中,__________是正確的。

  Aint a[5]={1,2,34,5);int b[5];b=a;  cout<<b

  Bint a[5]={12,3,4,5);int b[5] strcpy(a,b)  cout<<b;

  Cchar a[5]=1234;char b[5];strcpy(ba);  cout<<b

  Dchar a[5]=1234;char b[5];b=a;;    cout<<b

28.以下程序的輸出為

#include<iostreamh>

int w=3;

intfun(int)

void main(void)

{

  int w=10;

  cout<<fun(5)*w<<endl

}

int fun(int k)

{

 if(k==0)  return w;

 return(fun(k-1)*k);  

 }  

  A360    B3600    C1080  D1200  

 2 9.下列對派生類的描述中______是不正確的

  A.一個派生類可以作為另一個派生類的基類  

  B.派生類至少有一個基類   

  c:派生類的成員除了它自己的成員以外,還包含它的基類的成員

  D.派生類中繼承的基類的成員的訪問權(quán)限到派生類保持不變  

  30.關(guān)于構(gòu)造函數(shù)與析構(gòu)函數(shù)的下列說法中正確的是:

  ①在類中構(gòu)造函數(shù)與析構(gòu)函數(shù)都有固定的函數(shù)名。

  ②在類中構(gòu)造函數(shù)與析構(gòu)函數(shù)都有相同的作用。

  ③在類中構(gòu)造函數(shù)與析構(gòu)函數(shù)都可以定義多個。  

  ④在類中構(gòu)造函數(shù)與析構(gòu)函數(shù)都可以有返回值。  

  ⑤在類中構(gòu)造函數(shù)與析構(gòu)函數(shù)的參數(shù)都可以有默認值。 

  A.①和②    B.①    C.④和⑤  D.③和⑤。   

  二、填空(30)  

  ●基本概念題(8) 

  1.某類整數(shù)a滿足的條件為:①a小于等于100 a大于等于10,③a的十位數(shù)是個位

數(shù)的2倍或個位數(shù)是十位數(shù)的2倍。    ,‘        +

    請用一個邏輯表達式  (  1  ) a表示出來。

    2c++中編譯預(yù)處理有三種形式,分別是:______,___________,_____________

    3.面向?qū)ο蟪绦蛟O(shè)計語言的四個要素是:___________,__________________,_______________,__________

    ●閱讀程序?qū)懡Y(jié)果(10)

    4(1)若有宏定義:

    #define A 2

    #define B(n)(n*(A+2)n*2)

    則執(zhí)行語句“int w=2w*=2*(A*B(A+2))+3;"后,W的值為__________。

    5(1)[程序]

    #include<iostream.h>

    #define N 5

    void fun();

    void main()

    {  for(int i=1i<N;i++)

    fun()

  cout<<endl

}

void fun()

{

    static int a;

    int b=2

    cout<<(a+=3,a+b)<<" "

}

運行結(jié)果為:(  10  )

6(3)[程序]

#include<iostreamh>

void main()

{

  char s[]="I am a studentYou are a student too";

  int a[26]={0);

  char *p=S   

  while(*p++!=0)

  {

     if(*p>='A' && *p<='Z')a[*p-'A']++;

     else if(*p>='a' && *p<='z') a[*p-'a']++;

  }

    for(int i=0;i<26;i++)

      if(a[i]!=0)cout<<(char)(i+'a')<<""<<a[i]<<endl;

 }

程序運行后出現(xiàn)的前三行結(jié)果為:

  ( 11 )  ,  ( 12 )  ,  ( 13 )

7(3)[程序]

  #include<iostream.h>

  class Q

  {

    int x,y 

    static int z

 public

  Q(int a,int b){x=a+by=a*b;z+=x+y;}

  void show(){cout<<x<<'\t'<<y<<'\t'<<z<<endl}

  }; 

  int Q::z=10;

  void main()

  {

    Q ql(10,10);

    q1show();

    Q q2(20,20);

    q2.show();

    q1.show();

  }

程序運行后輸出的第一、二、三行分別是

  ( 14 )  ,  ( 15 )  ( 16 )

8(2)[程序]

 

#include<iostreamh>

class AA

{

  int x

public

  int y;

  AA(int a,int b){y=b-a;x=y+y;}

  int showx(void){return x)

};

class BBpublic AA

{

public

    BB(int c)AA(Cc+c){);

    int showy(void){return y)

);

class CCpublic AA

{

public

  CC(int d)AA(d,d+d){);

  int showy(void){return y;)

);

class DDpublic BBpublic CC

{

public

    DD(int e)BB(e+50),CC(e-50){};

)

void main()

{

  DD d(80);

  cout<<d.BB::showy()<<'\t'<<d.CC::showy()<<endl

cout<<d.BB::showx()<<'\t'<<d.CC::showx()<<endl;

}

程序運行結(jié)果為:

  (  17   )  ,  (    18   ) 

    ●完善程序(12)

    9(4)編寫一個程序采用遞歸方法逆序放置a數(shù)組中的元素。

    [方法說明]調(diào)用一個invert函數(shù)來進行數(shù)組逆置。invert(s,ij)函數(shù)采用遞歸方法實

現(xiàn),每次將S的第i個元素和第j個元素進行交換,直到i大于或等于j為止。

    [程序]

    #include<iostreamh>

    (   19  )    //函數(shù)invert()的原型說明

    void main()

    {

     int a[10]={0,12,3,45,6,7,8,9),i;

     (   20   )    //調(diào)用invert()函數(shù)

     for(i=0i<=9;i++)

          cout<<a[i]<<"";

     cout<<endl

     void invert(int  *s,int iint j)

      {

       int t;

       if(i<j)

       {

          t=*(s+i);

          (   21   )

          *(s+j)=t;

         (   22   )

       }

      }

    10(4)重載運算符“一=”,直接實現(xiàn)在一個字符串中刪除某個字符的功能。例如:

字符串“Microsoft Visual C++6O”與i做“一=”運算后的結(jié)果為“Mcrosoft Vsual C++

60。

    [程序]

    #include<iostream.h>

    #include<string.h>

    class string 

    {

       char*a

    public

      string(char *s)

      {

       if(s)

       {

             (   23   )

             strcpy(as);

       }

       else

         a=0;

      }

  string()

  {

    if(a) delete[ ]a;

   }

  string &operator -=(char c)

  void show()

  {

     cout<<a<<endl;

  }

 (   24   ) //重載函數(shù)的定義

 {

   char*p=a;

   while(*p)

  {

     if(*p==c)

     {

         for(char *q=p;*q;q++)

           (   25   )

     }

    else  (   26   )

  }

  return *this;

 void main()

 {

  string sl("Microsoft Visual C++60")

  s1show();

  char cl='i'

  sl-=cl

  s1.show();

 }

答案:

1.D 2.A 3.B 4.D 5.C6.B 7.A 8.D 9.C10.B11.C12.B13.B14.C 15.A16.C 17.B 18.B19.B 20.A

21.B 22.D 23.A 24.B 25.A26.C 27.C 28.B 29.D 30.B

二、填空答案  

  ●基本概念題(8) 

  1.某類整數(shù)a滿足的條件為:①a小于等于100 a大于等于10,③a的十位數(shù)是個位

數(shù)的2倍或個位數(shù)是十位數(shù)的2倍。  

    請用一個邏輯表達式  (  a<100 && a>=10 &&(a/10==(a%10)*2||2*(a/10)==(a%10))  ) a表示出來。

    2c++中編譯預(yù)處理有三種形式,分別是:__包含文件____,__宏定義___ ______,____條件與編譯_________

    3.面向?qū)ο蟪绦蛟O(shè)計語言的四個要素是:_封裝性__________,__繼承與派生________________,__多態(tài)性_____________,__重載________。

    ●閱讀程序?qū)懡Y(jié)果(10)

    4(1)若有宏定義:

    #define A 2

    #define B(n) (n*(A+2)n*2)

    則執(zhí)行語句“int w=2w*=2*(A*B(A+2))+3;"后,W的值為_____86_____。

    5(1)[程序]

    #include<iostream.h>

    #define N 5

    void fun();

    void main()

    {  for(int i=1i<N;i++)

    fun()

  cout<<endl

}

void fun()

{

    static int a;

    int b=2

    cout<<(a+=3a+b)<<" "

}

運行結(jié)果為:(  5  8  11   14 )

6(3)[程序]

#include<iostreamh>

void main()

{

  char s[]="I am a studentYou are a student too";

  int a[26]={0)

  char *p=S;   

  while(*p++!=0)

  {

     if(*p>='A' && *p<='Z')a[*p-'A']++;

     else if(*p>='a' && *p<='z') a[*p-'a']++

  }

    for(int i=0;i<26;i++)

      if(a[i]!=0)cout<<(char)(i+'a')<<""<<a[i]<<endl

 }

程序運行后出現(xiàn)的前三行結(jié)果為:

  ( a:4 )  ,  ( d:2 )    ( e:3 )

7(3)[程序]

  #include<iostream.h>

  class Q

  {

    int x,y; 

    static int z

 public

  Q(int aint b){x=a+b;y=a*b;z+=x+y;}

  void show(){cout<<x<<'\t'<<y<<'\t'<<z<<endl;}

  }; 

  int Q::z=10;

  void main()

  {

    Q ql(10,10);

    q1show()

    Q q2(20,20);

    q2.show();

    q1.show()

  }

程序運行后輸出的第一、二、三行分別是

  ( 20  100  130  )  ,  ( 40  400  570  )  ( 20  100  570 )

8(2)[程序]

 

#include<iostreamh>

class AA

{

  int x

public

  int y;

  AA(int a,int b){y=b-a;x=y+y;}

  int showx(void){return x;)

};

class BBpublic AA

{

public

    BB(int c)AA(Cc+c){);

    int showy(void){return y;)

);

class CCpublic AA

{

public

  CC(int d)AA(dd+d){);

  int showy(void){return y)

);

class DDpublic BB,public CC

{

public

    DD(int e)BB(e+50)CC(e-50){};

);

void main()

{

  DD d(80);

  cout<<d.BB::showy()<<'\t'<<d.CC::showy()<<endl

cout<<d.BB::showx()<<'\t'<<d.CC::showx()<<endl;

}

程序運行結(jié)果為:

  (  130  30   )    (    260  60   ) 

    ●完善程序(12)

    9(4)編寫一個程序采用遞歸方法逆序放置a數(shù)組中的元素。

    [方法說明]調(diào)用一個invert函數(shù)來進行數(shù)組逆置。invert(s,i,j)函數(shù)采用遞歸方法實

現(xiàn),每次將S的第i個元素和第j個元素進行交換,直到i大于或等于j為止。

    [程序]

    #include<iostreamh>

    (   void invert(int *, int, int)  )    //函數(shù)invert()的原型說明

    void main()

    {

     int a[10]={0,1,23,45,6,78,9)i;

     (   invert(a,0,9)   )    //調(diào)用invert()函數(shù)

     for(i=0;i<=9i++)

          cout<<a[i]<<",";

     cout<<endl

     void invert(int  *s,int i,int j)

      {

       int t;

       if(i<j)

       {

          t=*(s+i);

          (  *(s+i)=*(s+j)   )

          *(s+j)=t

         (   invert(s,i+1,j-1)   )

       }

      }

    10(4)重載運算符“一=”,直接實現(xiàn)在一個字符串中刪除某個字符的功能。例如:

字符串“Microsoft Visual C++6O”與i做“一=”運算后的結(jié)果為“Mcrosoft Vsual C++

60。

    [程序]

    #include<iostream.h>

    #include<string.h>

    class string 

    {

       char*a;

    public

      string(char *s)

      {

       if(s)

       {

             (   a=new char[strlen(s)+1]   )

             strcpy(a,s)

       }

       else

         a=0;

      }

  string()

  {

    if(a) delete[ ]a

   }

  string &operator -=(char c)

  void show()

  {

     cout<<a<<endl;

  }

 (  string &string::operator-=(char c)   ) //重載函數(shù)的定義

 {

   char*p=a

   while(*p)

  {

     if(*p==c)

     {

         for(char *q=p;*q;q++)

           (   *q=*(q+1)   )

     }

    else  (   p++   )

  }

  return *this;

 void main()

 {

  string sl("Microsoft Visual C++60")

  s1show();

  char cl='i'

  sl-=cl

  s1.show();

 }