《2010 C程序设计A参考答案.docx.pdf》由会员分享,可在线阅读,更多相关《2010 C程序设计A参考答案.docx.pdf(2页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、C+程序设计(A)卷 参考答案和评分标准一、单项选择题(一、单项选择题(3030 分,共分,共 1515 题,每小题题,每小题 2 2 分)分)题题 号号答答案案题题号号答答案案题题号号答答案案二、读程序,写运行结果(分,每题分)第 1 题.x=6d1=5.6d2=20.1第 2 题.80,-20第 3 题.Zhao第 4 题.Constructor1 called.Friskeys age is 1Constructor2 called.Toms age is3Destructor called.Destructor called.四、设计题(四、设计题(30,30,每题每题 1010)第
2、1 题.#include#include usingnamespacestd;int main()vector V;int x;1 1C C6 6A A1111B B2 2C C7 7B B1212C C3 3B B8 8C C1313D D4 4C C9 9D D1414A A5 5D D1010A A1515A Acin x;while(x!=0)V.push_back(x);cin x;int i;for(i=V.size()-1;i=0;i-)if(V i 0)cout Vi t;cout endl;for(i=0;i0)cout Vi t;cout=a&*str=Z)*str=*st
3、r+A-a;str+;第 3 题.#include usingnamespacestd;class CComplex friend ostream&operator (ostream&,CComplex&);public:CComplex ();CComplex (double a,double b=0);CComplex operator+(CComplex&rhs);CComplex operator-(CComplex&rhs);CComplex operator*(CComplex&rhs);public:double m_a,m_b;ostream&operator (ostream
4、&os,CComplex&rhs)os rhs.m_a;if(rhs.m_b 0)os rhs.m_b i 0)os +rhs.m_b i endl;return os;CComplex:CComplex ()CComplex:CComplex (double a,double b):m_a(a),m_b(b)CComplex CComplex:operator+(CComplex&rhs)int a=m_a+rhs.m_a;int b=m_b+rhs.m_b;return CComplex(a,b);CComplex CComplex:operator-(CComplex&rhs)int a=m_a-rhs.m_a;int b=m_b-rhs.m_b;return CComplex(a,b);CComplex CComplex:operator*(CComplex&rhs)int a=m_a*rhs.m_a-m_b*rhs.m_b;int b=m_a*rhs.m_b+m_b*rhs.m_a;return CComplex(a,b);