全国2013年1月自学考试C++程序设计真题(打印word版)(三)

时间:2015-02-09 17:52:43

微信搜索关注"91考试网"公众号,领30元,获取事业编教师公务员等考试资料40G

五、程序分析题(本大题共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函数的过程(如果需要形式参数,请给出形参类型和数量,以及返回值类型)

 


首页 上页 2 3 4 下页 尾页 3/6/6
微信搜索关注"91考试网"公众号,领30元,获取公务员事业编教师考试资料40G
【省市县地区导航】【考试题库导航】
 ★ 自学考试省级导航 ★ 
全国 A安徽 B北京 C重庆 F福建 G广东 广西 甘肃 贵州 H河南 河北 湖南 湖北 黑龙江 海南 J江苏 江西 吉林 L辽宁 N内蒙古 宁夏 Q青海 S山东 山西 陕西 四川 上海 T天津 X新疆 西藏 Y云南 Z浙江 历年真题分类检索
 ★ 自学考试导航 ★ 
 ★ 自考报名 ★ 

电脑版  |  手机版  |  返回顶部