已阅读5页,还剩15页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
作业1:输入两个变量,输出两个变量的最大值。要求:使用C+语言,使用max函数完成求最大值的操作。#includeintmax(intx,inty)return(xy?x:y);intmain(intargc,char*argv)inta,b;coutab;couta;return0;作业2:(1)输入下列简单C+程序,完成编译、连接、运行,熟悉C+程序的开发过程。#includeusingnamespacestd;constfloatPI=3.1416;voidmain() intiType;floatradius,a,b,area;coutiType;switch(iType)case1:coutradius;area=PI*radius*radius;couta;coutb;area=a*b;couta;area=a*a;coutusingnamespacestd;constdoublePI=3.1416;inlinefloatcirlearea(float);inlinefloatrectarea(float);inlinefloatzrectarea(float);voidmain() intiType;floatradius,a,b,area;coutiType;switch(iType)case1:coutradius;area=cirlearea(radius);couta;coutb;area=a*b;couta;area=a*a;coutusingnamespacestd;constdoublePI=3.1416;inlinefloatcirlearea(float,float);inlinefloatrectarea(float,float);inlinefloatzrectarea(float,float);voidmain() intiType;floatradius,a,b,area;float(*carea)(float,float);coutiType;switch(iType)case1:carea=cirlearea;coutradius;area=(*carea)(radius,a=0);couta;coutb;area=(*carea)(a,b);couta;area=(*carea)(a,a);coutusingnamespacestd;classRectprivate:intlength;intwidth;intperim;public:Rect() length=10;width=10;Rect(intlength,intwidth) this-length=length;this-width=width;voidsetLength(intlength) if(length0else cout0else coutusingnamespacestd;enumcpu_wordlenW16,W32,W64,W128,W256;classCPUpublic:CPU()frequency=0;wordlength=W16;coefficient=0;coutclasspointintx,y;public:point(inta,intb)x=a;y=b;cout#includeusingnamespacestd;classStudentpublic:Student(char*,int,bool);Student(constStudentStudent();Studentvoidprint();private:char*name;intage;boolsex;intlen;Student:Student(char*name,intage,boolsex)len=strlen(name);this-name=newcharlen+1;strcpy(this-name,name);this-age=age;this-sex=sex;Student:Student(constStudentthis-name=newcharlen+1;strcpy(this-name,);this-age=stu.age;this-sex=stu.sex;Student:Student()len=0;deletename;Studentthis-name=newcharlen+1;strcpy(this-name,);this-age=stu.age;this-sex=stu.sex;return*this;voidStudent:print()cout#includeclassCMelonSalepublic:CMelonSale(floatvWeight)m_Weight=vWeight;m_TotalWeight+=m_Weight;m_WeightStore.push_back(m_Weight);m_TotalNum+;CMelonSale()m_TotalNum-;staticvoidto
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 兽药质检员岗位质检考试试卷及答案
- 烧结机操作工岗位技能考试试卷及答案
- 7.2《归园田居》课件(内嵌视频) 2026-2027学年统编版高一语文必修上册
- 纤维板原料制备工操作评估竞赛考核试卷含答案
- 普通铣工安全生产规范水平考核试卷含答案
- 白蚁防治工安全理论能力考核试卷含答案
- 超重型汽车列车挂车工岗前岗中实操考核试卷含答案
- 石膏制品生产工岗前培训效果考核试卷含答案
- 电控设备组调工岗位安全应急考核试卷含答案
- 2026年生物安全法规解读培训考试及答案
- T/TMAC 248-2025连续石墨化炉能源消耗限额
- 武汉市2027届高中毕业生九月调研考试物理试卷(含答案及解析)
- 2026广东惠州市博罗县自然资源局补充招聘编外人员6人(第二次)笔试备考题库及答案详解
- IMDG Code 42-24 修正案 锂电池海运包装标记与标签规范 中文版(P903 包装标识更新全解)
- 供应链韧性的理论内涵与战略框架构建
- 《生态环境法典》企业负责人合规培训
- 2026年高中数学与思政融合课教学设计
- 改良早期预警评分系统在急诊内科危重患者院内转运中的应用
- GB/T 4340.2-2025金属材料维氏硬度试验第2部分:硬度计的检验与校准
- 2025年公务员考试《行测》模拟题及答案(详细解析)
- 幼儿园大班健康活动《预防感冒》课件
评论
0/150
提交评论