while(*p++=*p1++); cout< while(*p++=*p1++); delete[]=buf; return s1; } void main(void) { char s1[30]=‖about‖,s2[]=‖time‖; cout< 程序输出的第一行是___(12)__,第二行是 __(13)______。 9. [程序](3 分) #include cout< void main(void) { int a=3,b=6,k=4,m; m=fun(fun(a,b),fun(b,k)); cout<<‖m=‖< 程序输出的第一行是___(14)_____,第三行是 _(15)_______,第四行是___(16)___。 10. [程序] (2 分) #include public: void virtual f() {cout<<‖Base::f()‖< class A:public Base { public: void f(int a=0) {cout<<‖A::f()‖< class B:public A { void f(){cout<<‖B::f()‖< 江苏省计算机二级复习资料第26页 共70页 }; void main(void) { B b; Base *p=&b; A *q=&b; p->f(); p->g(); q->f(); q->g(); } 程序输出的第一行是___(17)___,第三行是__(18)______。 ●完善程序题,共12 分 11. 下面的程序功能是:将一个字符串中的单词分行输出。例如,对字符串;‖What is your name?‖执行程序后,输出结果为: What is your name? [程序] (4 分) #include char *nextWord(char **pp) { static char word[81]; while(**pp==‘ ‘) __(19)______; char *pw=word; while(**pp&&**pp!=‘ ‘) *pw++=*(*pp)++; ____(20)____; return ___(21)___; } void main(void) { char s[]=‖What is your name?‖,*ps=s; do{ cout< 原数组a 为: 1 3 2 数组b 为:2 7 1 操作后的数组a 为:1 3 1 4 6 8 2 6 2 8 9 10 4 7 8 [程序] (4 分) 8 9 10 江苏省计算机二级复习资料第27页 共70页 #include void f(int a[][COL],int b[]) { int i,j; for(__(23)___){ for(j=ROW-1;j>0;j--) if(a[j-1][i]>b[i]) ____(24)____; else break; __(25)_____; } } void main(void) { int a[ROW][COL]={1,3,2,4,6,8,8,9,10}; int b[COL]={2,7,1}; cout<<‖插入前数组中的数据依次为:‖<<‘\\n‘; for(int i=0;i for(int j=0;j for(int j=0;j node *CreateLink(void) //创建无序链表 { node *p1,*p2,*head=0; 江苏省计算机二级复习资料第28页 共70页 int a; cout<<‖产生一条无序链,请输入数据,以-1结束:‖; cin>>a; while(a!=-1){ p1=new node; p1->data=a; if(head==0) { head=p1; p2=p1; } else { ___(27)___; p2=p1; } cout<<‖请输入数据,以-1结束:‖; cin>>a; } p2->next=0; return (head); } void SorLink(node *&head) //通过移动每个节点的指针来完成链表排序 { node *q,*tq,*p,*tp; int flag=0; if (!head) return; for(q=head,tq=0;q;q=q->next){ for(tp=q,p=q->next;p;tp=p,p=p->next) if (q->data>=p->data) { //将p和q指向的两个节点所处位置互换 __(28)____; p->next=q; q=p; p=tp; } if(!tq) head=q; else tq->next=q; tq=q; } } void PrintLink(node *head) //打印链表 { node *p=head; cout<<‖链上各结点的数据为:\\n‖ ; while(p!=NULL) { cout< cout<<‖\\n‖; 江苏省计算机二级复习资料第29页 共70页 } void DeleteLind(node *head) //删除链表 { node *p1; while(head){ p1=head; head=head->next; ___(30)___; } } void main(void) { node *head=0; head=CreateLink(); PrintLink(head); SortLink(head); PrintLink(head); DeleteLink(head); } 2008春参考答案 一、选择题 题号 答案 题号 答案 二、填空题 题号 (1) (2) (3) (4) (5) (6) (7) (8) (9) 答案 析构函数 3 成员 友元 float或double 9 11 2 3 5 8 题号 (11) (12) (13) (14) (15) (16) (17) (18) (19) (20) 答案 s1=7531 about timeabout 6 4 6 6 m=6 B::f() A::f() (*pp)++ 题号 (21) (22) (23) (24) (25) (26) (27) (28) (29) 答案 word &ps i=0;i
2007春-2010年秋 - 江苏省计算机二级visual - C++ - 历年真题及(6)
2019-01-03 17:23
2007春-2010年秋 - 江苏省计算机二级visual - C++ - 历年真题及(6).doc
将本文的Word文档下载到电脑
下载失败或者文档不完整,请联系客服人员解决!