亚洲欧洲国产欧美一区精品,激情五月亚洲色五月,最新精品国偷自产在线婷婷,欧美婷婷丁香五月天社区

      自考

      各地資訊
      當(dāng)前位置:考試網(wǎng) >> 自學(xué)考試 >> 自考真題 >> 工學(xué)類(lèi) >> C語(yǔ)言程序設(shè)計(jì) >> 文章內(nèi)容

      排行熱點(diǎn)

      • 歷年真題
      • 模擬試題
      • 自考自答

      全國(guó)2012年1月自學(xué)考試C++程序設(shè)計(jì)試題_第5頁(yè)

      來(lái)源:考試網(wǎng) [ 2013年11月23日 ] 【大 中 小】

      四、完成程序題(本大題共5小題,每小題4分,共20分)

      46.在下面程序的下劃線處填上正確的語(yǔ)句,使其得到下面的輸出結(jié)果。

      x=2,y=3

      #include<iostream.h>

      class Sample

      {

      int x,y;

      public:

      Sample( ){

      x=y=0;

      }

      Sample(int a,int b){

      x=a;

      (__________)

      }

      void disp( )

      {

      cout<<"x="<<x<<",y="<<y<<endl;

      }

      }(____­_______)

      void main( )

      {

      Sample s(2,3),*p=&s;

      p - >disp();

      }

      47.在下劃線處填上適當(dāng)?shù)恼Z(yǔ)句,使程序的輸出結(jié)果如下:

      n=30

      #include< iostream.h >

      template< class T >

      class Sample

      {

      T n;

      public:

      Sample( ){ }

      Sample(T i){_________}

      Sample<T>&operator+(const Sample<T>&);

      void disp( ){cout<<"n="<<n<<endl;}

      };

      template<class T>

      Sample<T>&Sample<T>::operator+(const Sample<T>&s)

      {

      static Sample<T>temp;

      return temp;

      }

      void main( )

      {

      Sample<int>s1(10),s2(20),s3;

      s3=s1+s2;

      s3.disp();

      }

      48.在下劃線處填上適當(dāng)?shù)恼Z(yǔ)句,使程序的輸出結(jié)果如下:

      1 2 3 4 5 6 7 8 9 10

      #include<iostream.h>

      class Sample

      {

      int A[10][10];

      public:

      int &operator()(int,int);

      };

      int &Sample::operator()(int x,int y)

      {

      return A[x][y];

      }

      void main()

      {

      Sample a;

      int i,j;

      _________

      for(j=0;j<10;j++)

      _________

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

      cout<<a(i,1)<< " ";

      cout<<endl;

      }

      49.在下劃線處填上適當(dāng)?shù)木渥,完成函?shù)的定義。

      #include<iostream.h>

      class Sample

      {

      int x;

      public:

      Sample( ){ };

      _________{x=a;}

         _________{x=a.x++   +10;}

      void disp( ){cout<<"x="<<x<<endl;}

      };

      void main( )

      {

      Sample s1(2),s2(s1);

      s1.disp( );

      s2.disp( );

      }

      50.輸入一個(gè)字符串,將其逆序后輸出。

      #include<iostream>

      using namespace std;

      void main()

      {

      char a[50];memset(a,0,sizeof(a));

      int i=0,j;

      char t;

      cin.getline(a,50,'\ n';

      for(i=0,j=strlen(a)-1;i<_________;i++,j ―― )

      {

      t=a[i];

      a [j]=t;

      }

      cout<<a<<endl;

      }

      責(zé)編:may1205