《2009年9月计算机二级考试C考题》由会员分享,可在线阅读,更多相关《2009年9月计算机二级考试C考题(13页珍藏版)》请在金锄头文库上搜索。
1、一、选择题(1)-(10) 、 (21)-(40)每题 2 分, (11)-(20)每题 1 分,共 70 分)(1)下列数据结构中,属于非线性结构的是A)循环队列B)带链队列C)二叉树D)带链栈(2)下列数据结果中,能够按照“先进后出”原则存取数据的是A)循环队列B)栈C)队列D)二叉树(3)对于循环队列,下列叙述中正确的是A)队头指针是固定不变的B)队头指针一定大于队尾指针C)队头指针一定小于队尾指针D)队头指针可以大于队尾指针,也可以小于队尾指针(4)算法的空间复杂度是指A)算法在执行过程中所需要的计算机存储空间B)算法所处理的数据量C)算法程序中的语句或指令条数D)算法在执行过程中所需
2、要的临时工作单元数(5)软件设计中划分模块的一个准则是A)低内聚低耦合B)高内聚低耦合C)低内聚高耦合D)高内聚高耦合(6)下列选项中不属于结构化程序设计原则的是A)可封装D)自顶向下C)模块化D)逐步求精(27)有如下程序:#include using namespace std;class Toypublic:Toy(char* _n) strcpy (name,_n); count+;Toy() count-; char* GetName() return name; static int getCount() return count; private:char name10;stat
3、ic int count;int Toy:count=0;int mail()Toy t1(“Snoopy”),t2(“Mickey”),t3(“Barbie”);coutusing namespace std;class A public:A(int i):rl(i) void print() cout class A;下列声明中,与上述声明不等价的是A)template class A;B)template class A;C)template class A;D)template class A;(26)下列关于 C+流的描述中,错误的是A)coutA表达式可输出字符 AB)eof()函
4、数可以检测是否到达文件尾C)对磁盘文件进行流操作时,必须包含头文件 fstreamD)以 ios_base:out 模式打开的文件不存在时,将自动建立一个新文件 (27)有如下程序:#include using namespace std;class Toypublic:Toy(char* _n) strcpy (name,_n); count+;Toy() count-; char* GetName() return name; static int getCount() return count; private:char name10;static int count;int Toy:c
5、ount=0;int mail()Toy t1(“Snoopy”),t2(“Mickey”),t3(“Barbie”);coutusing namespace std;class A public:A(int i):rl(i) void print() coutusing namespace std;class Namechar name20;public:Name()strcpy(name,” ”); coutusing namespace std;public:AA() coutusing namespace std;class C1public:C1() coutusing namesp
6、ace std;class Publication /出版物类char name30;public:Publication(char *name=”未知名称”)strcpy(this-name,name);const char * getName()const return name; virtual const char * getType()const return “未知类型”;class Book: public Publication /书类public:Book(char *name): Publication(name)virtual const char * getType()
7、const return “书“;;void showPublication( Publication &p)cout#includeUsing namespace std;int main()int s=123, 234;cout20; i-=2) coutusing namespace std;class GrandChildpublic:GrandChild() strcpy (name,”Unknown”); const char * getName()const return name; virtual char * getAddress()const=0;private:char
8、name20;class GrandSon : public GrandChildpublic:GrandSonchar *name Char * getAddress() const return “Shanghai”; ;int main()GrandChild *gs=new GrandSon(“Feifei”);coutgetName()getAddress()#include using namespace std;class Wordpublic:Word(string s) : str(s) string getStr() return str; 【14】 const return (strclass Datapublic:void put (T v) val=v; 【15】 get() /返回数据成员 val 的值,返回类型不加转换 return val; private:T val;