设为首页    加入收藏

自学考试省级导航

全国 A安徽 B北京 C重庆 F福建 G广东 广西 甘肃 贵州 H河南 河北 湖南 湖北 黑龙江 海南 J江苏 江西 吉林 L辽宁 N内蒙古 宁夏 Q青海 S山东 山西 陕西 四川 上海 T天津
     X新疆 西藏 Y云南 Z浙江 历年真题分类检索

全国2013年1月自学考试C++程序设计真题(打印word版)(六)
2015-02-09 17:52:43 来源:91考试网 作者:www.91exam.org 【

五、程序分析题(本大题共4小题,每小题5分,共20分)

51.给出下面程序的输出结果

    #include<iostream>

    using namespace std;

    class base

    {

      int x;

public :

      void setx(int a) { x =a; }

 int getx( ) { return x;

};

void main( )

{

      int *p;

      base a;

      a. setx ( 15) ;

      p = new int( a. getx( )) ;

cout<< *p;

}

52.给出下列程序的输出结果

  #include < iostream >

 #include < complex >

  #include < string >

  using namespace std ;

  void main( )

    complex < int > fsl ( 5 ,6) ;

    complex < float > fs2( 7. 5 ,8.5) ;

    string strl ('' real is: '' ) ;

    string str2 ('' image is : '') ;

    cout<< strl<< fsl. real( )<< ', ' << str2<< fsl. imag( ) << endl;

cout<< strl<< fs2. real( ) << ', '<< str2<< fs2. imag( ) << endl;

}

53.给出下面程序的输出结果

  #include < iostream >

  using namespace std;

  class base

 private :

    int x;

  public :

    void setx(int a) { x = a; }

    int getx( ){ return x;}

 };

  void main( )

    base a,b;

    a. setx( 89) ;

    b=a;

    cout<< a. getx( ) << endl;

 cout<< b. getx( ) << endl;

54.给出下面程序的输出结果

 #include <iostream >

  using namespace std ;

  void main( )

  {

  int a[ ] = { 10,20,30,40 } , * pa = a;

  int * &pb =pa;

  pb + +;

  cout<< * pa<< endl;

 

六、程序设计题(本大题共1小题,每小题10分,共10分)

55.在字符串类string中实现一个判断函数,该函数功能是统计某一字符串类对象(仅有单词和空格组成)有多少个单词,同时保存所有单词在字符串中的起始地址(设该字符串不超过100个单词)

 #include<iostream.h>

 #include<string>

 class str{

   string s; int n,a[100],j,1;

   public: str( string& a){s=a;n =0;j =0;l =0;}

     ....test(....);

     int*geta(){return a;}

   } ;

 请写出test函数的过程(如果需要形式参数,请给出形参类型和数量,以及返回值类型)

 

Tags:自学考试 历年真题
】【打印繁体】 【关闭】 【返回顶部
上一篇浙江省2012年7月高等教育自学考试.. 下一篇浙江省2012年10月高等教育自学考..

网站客服QQ: 960335752 - 14613519 - 48225117