自考

各地资讯
当前位置:考试网 >> 自学考试 >> 自考真题 >> 工学类 >> C语言程序设计 >> 文章内容

排行热点

全国2011年10月高等教育自学考试C++程序设计试题_第6页

来源:考试网 [ 2011年12月10日 ] 【大 中 小】
49.在下面程序的下划线处填上正确的语句,使其得到下面的输出结果。
20
21
22
a[0]=20
a[1]=21
a[2]=22
程序清单如下:
#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 [3],*p;
a[0].setx(20);
a[1].setx(21);
a[2].setx(22);
for(p=a; p<a+3;p++)
____________
for(int i=0;i<=2;i++)
____________
}
50.在下面程序中的下划线处填上适当的程序,使程序的输出结果如下:
x=2,y=3
源程序如下:
#include<iostream.h>
class Sample
{
int x,y;
public:
Sample(){x=y=0;}
Sample(________){x=a;y=b;}
void disp()
{
cout<<"x="<<x<<",y="<<y<<endl;
}
} ;
void main()
{
Sample s(2,3),________
P - >disp();
}
五、程序分析题(本大题共2小题,每小题5分,共10分)
51.请给出下面程序的输出结果
#include<iostream>
using namespace std;
void fun()
{
static int n=25;
n--;
cout<<"n="<<n<<endl;
}
void main()
{
for(int i=0;i<=2;i++)
fun();
}
52.请给出下面程序的输出结果
#include<iostream>
using namespace std;
class point
{
int num;
public:
point(int n)
{cout<<"Initializing"<<n<<endl;num=n;}
} ;
void main()
{
point A(88);
cout<<"Entering main"<<endl;
}
六、程序设计题(本大题共l小题,共10分)
53.给定两个字符串对象S,P(P的长度小于S),实现一判断函数find,检测S是否完全包含P(串P是S的子串),若

包含则返回P第一个字符在串S中的起始地址,否则返回-1。
#include<iostream. h>
#include<string>
class str{
string s,p;
public:str(string&a,string&b){s=a;p=b;}
...find(...);
};
请写出函数的过程(如果需要形式参数,请给出形参类型和数量,以及返回值类型)

首页 1 2 3 4 5 6 尾页
责编:snrvge