华南俳烁实业有限公司

自考

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

排行熱點

全國2011年10月高等教育自學考試C++程序設(shè)計試題_第6頁

來源:考試網(wǎng) [ 2011年12月10日 ] 【大 中 小】
49.在下面程序的下劃線處填上正確的語句,使其得到下面的輸出結(jié)果。
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.在下面程序中的下劃線處填上適當?shù)某绦,使程序的輸出結(jié)果如下:
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.請給出下面程序的輸出結(jié)果
#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.請給出下面程序的輸出結(jié)果
#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;
}
六、程序設(shè)計題(本大題共l小題,共10分)
53.給定兩個字符串對象S,P(P的長度小于S),實現(xiàn)一判斷函數(shù)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(...);
};
請寫出函數(shù)的過程(如果需要形式參數(shù),請給出形參類型和數(shù)量,以及返回值類型)

首頁 1 2 3 4 5 6 尾頁
責編:snrvge
久治县| 彭山县| 滨海县| 双流县| 诸城市| 滁州市| 灵石县| 巫山县| 新沂市| 华阴市| 祁阳县| 徐水县| 稻城县| 治县。| 祥云县| 军事| 沙河市| 通河县| 湖州市| 马尔康县| 花莲市| 上杭县| 海丰县| 普定县| 古浪县| 南木林县| 白河县| 尉犁县| 达州市| 云和县| 白城市| 罗江县| 农安县| 南江县| 尤溪县| 板桥市| 临桂县| 隆子县| 阳泉市| 綦江县| 同德县|