东南大学C第二学期期末复习资料二含标准答案.doc

收藏

编号:2574624    类型:共享资源    大小:91.02KB    格式:DOC    上传时间:2020-04-21
8
金币
关 键 词:
东南大学 东大 第二 学期 期末 复习资料 标准答案
资源描述:
^. 一、 选择题:(每题1分,共30分) 1. 以下程序的输出结果是 C A) 1 B) 7 C) 9 D) 11 #include void fut (int**s,int p[2][3]) {**s=p[1][1]; } void main() {static int a[2][3]={1,3,5,7,9,11}; int *p; p=new int; fut(&p,a); cout<<*p< void main() {static int a[]={2,4,6,8,10}; int y=0,x,*p; p=&a[1]; for(x=0;x<3;x++) y+=*(p+x); cout< int f(int a,int b) { if(a>b) return b+a; else cout< class X{ public: void virtual f(){cout<<"X:11"<f(); px->g(); } 程序输出的第一行是 ,第二行是 ,第三行是 _。 8. 程序 #include class A x=1 A_1 A_2 A_2 2 ~A A_2 3 ~A A_2 4 ~A 4 ~A 3 ~A { int x; public: A(int a) { x=a; cout<<"x="< class A{ int y; static int x; public: operator int(){return x+y;} A operator ++(int){return A(x++,y++);} A(int x=2,int y=3){A::x=x+x;A::y=y+y;} void print(){cout<<"x="< class A{ public: int i; void print(){cout<print(); pb=&c; pb->print(); pa=&c; pa->print(); } 三、 完善程序 1. 1. 下面程序的功能是:先输入一行字符串,并从输入的字符串中找到最小的字符(其ASCII值最小),用min保存该字符。然后将该字符前的所有字符顺序向后移动一个字符的位置。最后,将保存的字符放在该字符串的第0个位置上。例如:设输入的字符串为“bcdfae”,其中字母a为最小字符,经移动处理后,输出的字符串为“abcdfe”。 #include void fun( ) { // char *str char mun,*q,*p; ; // p=q=str min = *p++; while(*p!=0){ if( ){min = *p; q = p ; } // *pstr //p--,q-- *q = min; } void main(){ char str[80]; cin.getline(str,80); fun(str); cout< #include class A{ public: static int i; char *ps; A(char ){ //*s ps=new char[strlen(s)+1]; strcpy( ,s); //ps } ~A(){ if( ) cout<<"The end"; //i==0 else cout<<"at this time of day!\n "; if(ps) delete[]ps; i++; } A & operator=(A &b){ if(b.ps){ ps=new char[strlen( )+1]; // b.ps strcpy(ps,b.ps); } else ps=0; return ; //*this } }; int A::i; void main(){ A s1("programming"),s2("C++ languge"); cout< #include char *sercher(char *s,char ch){ while(*s) if(*s++==ch) return ; //s-1 return 0; } void dele(char *s,char ch){ char *p1=search(s,ch),*p2=p1+1; while(*p2) *p1++= //*p2++ *p1=\0; } void add(char *s,char ch){ while(*s) s++; =ch;*s=\0; //*s++ } void main(){ char str[80]="abc12123",c; cout<>c; void ;if(search(str,c)) fp=dele; //(*p)(char *,char) else fp=add; fp( );cout< struct node{ int grade,n; long num; node *point; }; node *trans(node *h,int n){ //建立含报名者的档案链表 node *p; p=new node; cin>>p->num>>p->grade; p->n=0; ; // node *h=p for(int i=0;ipoint=new node; ; //p=p->point; cin>>p->num>>p->grade; p->n=0; } p->point=NULL; return h; } node *sort(node *head,int n){ //按成绩排名次并输出 node *p,*q; int t=0,k=1; p=head; while(k<=n){ p=head; while(p!=NULL) if( &&p->grade>t){ //p->n==0 t=p->grade; q=p; p=p->point; } else p=p->point; q->n=k; ; //k++; ; //t=0; cout<num<<\t<grade<<\t<n<<\n; } return head; } void main(){ node *student; int n; student=NULL; cin>>n; student=trans(student,n); cout<<"\nnumber:"<<\t<<"grade:"<<\t<<"排名:\n"; student=sort(student,n); } 5. 以下程序定义了一个二维坐标点类Point,派生矩形类Square。矩形左下角坐标从基类继承,矩形类只定义右上角坐标,还定义表示颜色的字符串。执行下面的主程序将得到结果: 矩形s1: x=1 y=3 width=5 , high=6 , color = red 矩形s2: x=1 y=3 width=5 , high=6 , color = redYellow [程序10分] #include #include class Point{ private: double x,y; public: Point(double xv=0,double yv=0){x=xv;y=yv;} double getx(){return x;} double gety(){return y;} void Show(){cout<<"x="< class List{ int size;//表示动态线性表的长度 double *list; //动态线性表的指针 public: List(int=1,double=0.0); ~List(){delete []list;}; List & operator=(const List&); friend ostream& operator<<(ostream & , List &); friend istream& operator>>(istream &, List &); }; List::List(int sz,double t){ size=sz; list= ; //new double[size] for(int i=0;i>(istream &is, List & v){ int i; for (i=0;i>v.list[i]; // is } return is; } void main(){ List a(4),b(4); cout<<"input List b:\n"; cin>>b; cout<<"b:"<
展开阅读全文
提示  得力文库 - 分享文档赚钱的网站所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
关于本文
本文标题:东南大学C第二学期期末复习资料二含标准答案.doc
链接地址:https://www.deliwenku.com/p-2574624.html
关于得利文库 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com  

收起
展开