查看文章 |
全国高等教育自学考试 计算机及应用专业(独立本科段)计算机信息管理(独立本科段)(2008年版)C++程序设计(刘振安 主编)考前辅导资料 1、教材上10章习题的全部答案、教材上的例子程序源代码(帮助你上机运行查看结果)、根据考试大纲编写的八套模拟试题(含答案)使你在考试中轻松过关,现有偿转让,全部资料是电子版338KB,通过EMAIL传送。有需要者短信联系:13011697612并打款 68元工商银行9558 8116 0710 0056 471 董玉刚,款到发货,非诚勿扰.也可通过淘宝网交易.2、C++程序设计考前辅导视频(与教材内容大致相同),对你学习教材内容大有帮助,12讲,电子版600MB,通过EMAIL传送。有需要者打款 68元工商银行9558 8116 0710 0056 471 董玉刚,款到发货,非诚勿扰.3、全国高等教育自学考试C++程序设计2008年10月\2009年1月真题及参考答案电子版80KB,通过EMAIL传送。有需要者短信联系:13011697612并打款 36元工商银行9558 8116 0710 0056 471 董玉刚,款到发货,非诚勿扰.4、2009年3月最新版山东省高等教育自学考试C++实践环节辅导资料:辅导教材上全部的C++程序及运行结果电子版、实践环节课堂辅导实录、实践环节考核重点内容,现有偿转让,全部36元,款到发货,非诚勿扰。 高等教育自学考试C++程序设计课程习题答案 2008年10月全国高等教育自学考试C++程序设计考试试题
二. 填空(20分) 21. 设要把一个文件输出流对象myFile与文件“f:\myFile.txt”相关联,所用的C++语句是: 22. C++中ostream类的直接基类是: 23. 运算符[ ]只能用 运算符来重载,不能用友元运算符来重载 24. 定义虚函数所用的关键字是: 25. vector类中用于返回向量中第一个对象的方法是: 26. 在C++中,利用向量类模板定义一个具有20个char的向量E,其元素均被置为字符‘t’,实现此操作的语句是: 27.类的继承是指子类继承基类的 和成员函数 28.不同对象可调用相同名称的函数,但可导致不同的行为现象称为: 29. 指令指示一个编译器将一个源文件嵌入到带该指令的源文件之中 30.设类A有成员函数 void Fun(void); 若要定义一个指向类成员函数的指针变量pafn来指向Fun,该指针变量的声明语句是: 31.设在程序中使用如下语句申请一个对象数组:Point *ptr = new Point[2]; 则在需要释放ptr 指向动态数组对象时,所使用的语句是: 32.在保护派生类中,基类权限为Private的成员在派生类中: 33. 类A有如下成员: int a::fun(double x){ return (int) x / 2;} int a::fun(int x){ return x * 2;} 设a 为类A的对象,在主函数中有int s=a.fun(6.0)+a.fun(2),则执行该语句后,s的值为: 34.对象传送的消息一般由三部分组成:接收对象名,调用操作名和: 35.将指向对象的指针作为函数参数,形参是对象指针,实参是对象的: 36.在String类的find成员函数来检索主串中是否含有指定的子串时,若在主串中不含指定的子串,find函数的返回值是: 37.C++中,声明布尔类型变量所用的关键字是: 38.执行下列代码:int a=29,b=100; cout<<setw(3)<<a<<b<<endl; 程序输出结果是: 39.执行下列代码:cout <<”Hex:”<<hex<<255; 程序输出结果是: 40. C++语言中可以实现输出一个换行符并刷新流动功能的操控符是:
41. #include <iostream.h> main() { int x=5,y=6; const int *p=&x;*p=y; cout<<*P<<endl;
42. #include <iostream.h> class f { private:int x,y; public:f1() { x=0;y=0; } print() { cout<<x<<"<<y<<endl; } } main() { fa; a.f1(1,1); a.print(); } 43. #include <iostream.h> class f { private: int x=0,y=0; public: void f1(int a,int b) { x=a; y=b; } void get() { cout<<x<<','<<y<<endl; } } main() { fa; a.f1(1,3); a.get(); } 44. #include <iostream.h> class point { private: float x; public: void f(float a) { x=a; } void f() { x=0; } friend float max(point &a,point &b); }; float max(point &a,point &b) { return (a.x>b.x)? a.x:b.x; } main() { point a,b; a.f(2.2); b.f(3.3); cout<<a.max(a,b); } 45. #include <iostream.h> template<class T> CLASS f { private: T x,y; public: void f1(Ta,Tb) { x=a; y=b; } T max() { return(x>y)?x:y; } }; main() { fa; a.f1(1.5,3.8); cout<<a.x<<a.y<<a.max()<<endl; }
46. 完成下列类中的成员函数的定义 Class point { private: int m,n; public: point(int,int); point(point &); }; point::point(int a,int b) { m=a; =b; } point::point( ) { m=t.m; n=t.n; }
四. 完成程序(20分) 46. 完成下列类中的成员函数的定义 Class point { private: int m,n; public: point(int,int); point(point &); }; point::point(int a,int b) { m=a; =b; } point::point( ) { m=t.m; n=t.n; }
#include<iostream> using namespace std; Pi=3.14159; void main() { double r; cout<<"r="; ; double l=2.0*Pi*r; double s=Pi*r*r; cout<<"\n The long is:"<<l<<endl; cout<<"the area is:"<<s<<endl; }
#include<iostream> #include<fstream> using namespace std; class complex { public: int real; int imag; complex(int r=0,int i=0) {real=r;imag=i;} }; complex operator+( ,complex &b) {int r=a.real+b.real; it i=a.imag+b.imag; return ; } void main() {complex x(1,2),y(3,4),z; z=x+y; cout<<z.real<<"+"<<z.imag<<";"<<endl; }
程序输出如下:1,9 50,30 #include<iostream> using namespace std; class base { private: int m; public: base(){ }; base(int a):m(a){ } int get(){return m;} void set(int a){m=a;} }; void main() { base *ptr=new base[2]; ptr->set(30); ptr= ; ptr->set(50); base a[2]={1,9}; cout<<a[0].get()<<","<<a[1].get()<<endl; cout<<ptr-> get()<<","; ptr=ptr-1; cout<< <<endl; delete[]ptr; } 50. #include<iostream> using namespace std; void main() { float a,b; ;//函数cha的原型声明 a=12.5;b=6.5; float c= ;//调用函数cha cout<<c<<endl; } float cha(float x,float y) { float w; w=x-y; return w; }
51. #include<iostream> template<class T> class Sample {T n; public:Sample (T i){n=i;} int oerator ==(Sample &); }; template<clsaa T> int Sample<T>::operator ==(Sample &s) {if (n==s.n) return 1;else return 0; } void main() {Sample <int> s1(2),s2(3); cout<<"s1与械的数据成员"<<(s1==s2? "相等":"不相等")<<endl; Sample<double>s3(2.5),s4(2.5); cout<<"s3与械的数据成员"<<(s3==s4?"相等":"不相等") <<endl; }
#include<iostream> using namespace std; template<class T> T max(T ml,T m2) {return(m1>m2)?m1:m2; } void main() { cout<<max(1,7)<<"\t"<<max(2.5,5.0)<<endl; cout<<max('y','b')<<"\t"<<max("A","a")<<endl;
#include<iostream> using namespace std; class A {public:int x; A(){ } A(int a){x=a;} int get(int a){return x+a;} }; void main() {A a(8); int(A::*p)(int); p=A::get; cout<<(a.*p)(5)<<endl; A *pi=&a; cout<<(pi->*p) (7)<<endl; }
#include<iostream> using namespace std; class book {char *title; char *author; int numsold; public: book(){} book(const char *str1,const char *str2,const int num) {int len=strlen(str1);title=new char[len+1]; strcpy(title,str1); len=strlen(str2); author=net char[len+1]; srtcpy (author,str2); numsold=num; } void setbook(const char *str1,const char *str2,const int num) {int len=strlen(str1); title=new char[len+1]; strcpy(title,str1); len=strlen(str2); author=new char[len+1]; strcpy(author,str2); numsold=num; } ~book() delete title; delete author; } void print (ostream&output) {output<<"书名:"<<title<<endl; output<<"作者:"<<author<<endl; output<<"月销售量:"<<numsold<<endl; } }; void main() {book obj1("数据结构","严小华",200),obj2; obj1 print(cout); obj2 setbook("C++程序设计","谭浩强",210); obj2 print(cout); }
55.在三角形类TRI实现两个函数,功能是输入三个顶点坐标判断是否构成三角形。 #include<iostream.h> #include<math.h> class point{private:float x,y; public:point(float a,float b){x=a;y=b;} point(){x=0;y=0;} void set(float a,float b){x=a;y=b;} float get x(){return x;} float get y(){return y;} }; clsaa tri { point x,y,z; float s1,s2,s3; public: .............settri(..............) ;//用于输入三个顶点坐标 ............test(..............);//用于判断是否构成三角形 };
全国2009年1月高等教育自学考试
|